Author: Wim Lavrijsen <[email protected]>
Branch: cppyy-packaging
Changeset: r94770:1e6f1f90453c
Date: 2018-06-15 23:27 -0700
http://bitbucket.org/pypy/pypy/changeset/1e6f1f90453c/
Log: merge default into branch
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -7,9 +7,9 @@
.. branch: cppyy-packaging
-Upgrade to backend 0.6.0, support exception handling from wrapped functions,
-update enum handling, const correctness for data members and associated tests,
-support anonymous enums, support for function pointer arguments
+Upgrade to backend 1.1.0, improved handling of templated methods and
+functions (in particular automatic deduction of types), improved pythonization
+interface, and a range of compatibility fixes for Python3
.. branch: socket_default_timeout_blockingness
diff --git a/pypy/interpreter/pyparser/automata.py
b/pypy/interpreter/pyparser/automata.py
--- a/pypy/interpreter/pyparser/automata.py
+++ b/pypy/interpreter/pyparser/automata.py
@@ -23,6 +23,10 @@
ERROR_STATE = chr(255)
+# NB: all non-ascii bytes (>= 128) will be turned into 128
+NON_ASCII = chr(128)
+
+
class DFA:
# ____________________________________________________________
def __init__(self, states, accepts, start = 0):
@@ -36,7 +40,10 @@
for key in state:
if key == DEFAULT:
continue
- maximum = max(ord(key), maximum)
+ ordkey = ord(key)
+ if ordkey > 128:
+ raise ValueError("DFA does not support matching of
specific non-ASCII character %r. Use NON_ASCII instead" % key)
+ maximum = max(ordkey, maximum)
self.max_char = maximum + 1
defaults = []
@@ -72,6 +79,8 @@
i = pos
for i in range(pos, len(inVec)):
item = inVec[i]
+ if ord(item) > 0x80:
+ item = NON_ASCII
accept = self.accepts[crntState]
crntState = self._next_state(item, crntState)
if crntState != ERROR_STATE:
@@ -103,6 +112,8 @@
i = pos
for i in range(pos, len(inVec)):
item = inVec[i]
+ if ord(item) > 0x80:
+ item = NON_ASCII
accept = self.accepts[crntState]
if accept:
return i
diff --git a/pypy/interpreter/pyparser/test/test_automata.py
b/pypy/interpreter/pyparser/test/test_automata.py
--- a/pypy/interpreter/pyparser/test/test_automata.py
+++ b/pypy/interpreter/pyparser/test/test_automata.py
@@ -1,4 +1,7 @@
-from pypy.interpreter.pyparser.automata import DFA, NonGreedyDFA, DEFAULT
+# coding: utf-8
+import pytest
+
+from pypy.interpreter.pyparser.automata import DFA, NonGreedyDFA, DEFAULT,
NON_ASCII
def test_states():
d = DFA([{"\x00": 1}, {"\x01": 0}], [False, True])
@@ -27,3 +30,18 @@
d = NonGreedyDFA([{"a": 1}, {DEFAULT: 0}], [False, True])
assert d.recognize("a,a?ab") == 1
assert d.recognize("c") == -1
+
+def test_nonascii():
+ d = DFA([{"a": 1}, {NON_ASCII: 1}], [False, True])
+ input = u"aüüüü".encode("utf-8")
+ assert d.recognize(input) == len(input)
+ assert d.recognize("c") == -1
+ assert d.recognize("ü") == -1
+
+ d = NonGreedyDFA([{NON_ASCII: 0, "b": 1}, {"b": 0}], [False, True])
+ input = u"üübbbb".encode("utf-8")
+ assert d.recognize(input) == len(u"üüb".encode("utf-8"))
+ assert d.recognize("c") == -1
+
+ pytest.raises(ValueError, DFA, [{"\x81": 2}], [True])
+
diff --git a/pypy/interpreter/test/test_function.py
b/pypy/interpreter/test/test_function.py
--- a/pypy/interpreter/test/test_function.py
+++ b/pypy/interpreter/test/test_function.py
@@ -455,6 +455,8 @@
assert repr(B().f).startswith("<bound method B.f of <")
assert repr(A().f).endswith(">>")
+ assert repr(type(A.f)) == repr(type(A().f)) == "<type
'instancemethod'>"
+
def test_method_call(self):
class C(object):
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -688,7 +688,7 @@
Function.typedef.acceptable_as_base_class = False
Method.typedef = TypeDef(
- "method",
+ "instancemethod",
__doc__ = """instancemethod(function, instance, class)
Create an instance method object.""",
diff --git a/pypy/module/_cppyy/ffitypes.py b/pypy/module/_cppyy/ffitypes.py
--- a/pypy/module/_cppyy/ffitypes.py
+++ b/pypy/module/_cppyy/ffitypes.py
@@ -119,7 +119,7 @@
value = space.bytes_w(w_value)
if len(value) != 1:
raise oefmt(space.w_ValueError,
- "usigned char expected, got string of size %d",
len(value))
+ "unsigned char expected, got string of size %d",
len(value))
value = rffi.cast(rffi.CHAR, value[0])
return value # turn it into a "char" to the annotator
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit