Author: Carl Friedrich Bolz <[email protected]>
Branch: optinfo-into-bridges-3
Changeset: r90357:8c7255d2aefd
Date: 2017-02-24 13:02 +0100
http://bitbucket.org/pypy/pypy/changeset/8c7255d2aefd/

Log:    merge default

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -74,7 +74,7 @@
 ^rpython/doc/_build/.*$
 ^compiled
 ^.git/
-^.hypothesis/
+.hypothesis/
 ^release/
 ^rpython/_cache$
 
diff --git a/extra_tests/README.txt b/extra_tests/README.txt
new file mode 100644
--- /dev/null
+++ b/extra_tests/README.txt
@@ -0,0 +1,5 @@
+The tests in this directory are a complement to lib-python/3/test/.
+
+They are meant to run on top of a compiled pypy3 or CPython3.5 in an
+environment containing at least pytest and hypothesis, using a command like
+'pytest extra_tests/'.
diff --git a/extra_tests/pytest.ini b/extra_tests/pytest.ini
new file mode 100644
diff --git a/extra_tests/test_unicode.py b/extra_tests/test_unicode.py
new file mode 100644
--- /dev/null
+++ b/extra_tests/test_unicode.py
@@ -0,0 +1,34 @@
+import pytest
+from hypothesis import strategies as st
+from hypothesis import given, settings, example
+
+from unicodedata import normalize
+
+# For every (n1, n2, n3) triple, applying n1 then n2 must be the same
+# as applying n3.
+# Reference: http://unicode.org/reports/tr15/#Design_Goals
+compositions = [
+    ('NFC', 'NFC', 'NFC'),
+    ('NFC', 'NFD', 'NFD'),
+    ('NFC', 'NFKC', 'NFKC'),
+    ('NFC', 'NFKD', 'NFKD'),
+    ('NFD', 'NFC', 'NFC'),
+    ('NFD', 'NFD', 'NFD'),
+    ('NFD', 'NFKC', 'NFKC'),
+    ('NFD', 'NFKD', 'NFKD'),
+    ('NFKC', 'NFC', 'NFKC'),
+    ('NFKC', 'NFD', 'NFKD'),
+    ('NFKC', 'NFKC', 'NFKC'),
+    ('NFKC', 'NFKD', 'NFKD'),
+    ('NFKD', 'NFC', 'NFKC'),
+    ('NFKD', 'NFD', 'NFKD'),
+    ('NFKD', 'NFKC', 'NFKC'),
+    ('NFKD', 'NFKD', 'NFKD'),
+]
+
[email protected]('norm1, norm2, norm3', compositions)
+@settings(max_examples=1000)
+@example(s=u'---\uafb8\u11a7---')  # issue 2289
+@given(s=st.text())
+def test_composition(s, norm1, norm2, norm3):
+    assert normalize(norm2, normalize(norm1, s)) == normalize(norm3, s)
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
@@ -158,6 +158,8 @@
 not on PyPy 3.x.  The latter is used to get an app-level unicode string
 by decoding the RPython string, assumed to be utf-8.
 
+.. branch: space-wrap
+
 .. branch: fix_bool_restype
 
 Fix for ``ctypes.c_bool``-returning ctypes functions
diff --git a/pypy/module/cpyext/test/test_pystate.py 
b/pypy/module/cpyext/test/test_pystate.py
--- a/pypy/module/cpyext/test/test_pystate.py
+++ b/pypy/module/cpyext/test/test_pystate.py
@@ -178,7 +178,6 @@
             ("bounce", "METH_NOARGS",
             """
             PyGILState_STATE gilstate;
-            PyThreadState *tstate;
             PyObject *dict;
 
             if (PyEval_ThreadsInitialized() == 0)
diff --git a/rpython/rlib/runicode.py b/rpython/rlib/runicode.py
--- a/rpython/rlib/runicode.py
+++ b/rpython/rlib/runicode.py
@@ -5,7 +5,7 @@
 from rpython.rlib.unicodedata import unicodedb
 from rpython.tool.sourcetools import func_with_new_name
 from rpython.rtyper.lltypesystem import lltype, rffi
-from rpython.rlib import jit
+from rpython.rlib import jit, nonconst
 
 
 if rffi.sizeof(lltype.UniChar) == 4:
@@ -373,7 +373,12 @@
                             pos += 1
                             _encodeUCS4(result, ch3)
                             continue
-                    if not allow_surrogates:
+                    # note: if the program only ever calls this with
+                    # allow_surrogates=True, then we'll never annotate
+                    # the following block of code, and errorhandler()
+                    # will never be called.  This causes RPython
+                    # problems.  Avoid it with the nonconst hack.
+                    if not allow_surrogates or nonconst.NonConstant(False):
                         ru, rs, pos = errorhandler(errors, 'utf8',
                                                    'surrogates not allowed',
                                                    s, pos-1, pos)
diff --git a/rpython/translator/c/test/test_newgc.py 
b/rpython/translator/c/test/test_newgc.py
--- a/rpython/translator/c/test/test_newgc.py
+++ b/rpython/translator/c/test/test_newgc.py
@@ -1730,7 +1730,11 @@
                      (ulimitv, ' '.join(args),)]
             popen = subprocess.Popen(args1, stderr=subprocess.PIPE)
             _, child_stderr = popen.communicate()
-            assert popen.wait() == 134     # aborted
+            assert popen.wait() in (-6, 134)     # aborted
+            # note: it seems that on some systems we get 134 and on
+            # others we get -6.  Bash is supposed to translate the
+            # SIGABRT (signal 6) from the subprocess into the exit 
+            # code 128+6, but I guess it may not always do so.
             assert 'out of memory:' in child_stderr
             return '42'
         #
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to