[pypy-commit] pypy py3.6: hg merge default

arigo pypy.commits at gmail.com
Sat Aug 17 02:43:52 EDT 2019


Author: Armin Rigo <arigo at tunes.org>
Branch: py3.6
Changeset: r97200:9122fab2808f
Date: 2019-08-17 08:43 +0200
http://bitbucket.org/pypy/pypy/changeset/9122fab2808f/

Log:	hg merge default

diff --git a/extra_tests/cffi_tests/cffi1/test_recompiler.py b/extra_tests/cffi_tests/cffi1/test_recompiler.py
--- a/extra_tests/cffi_tests/cffi1/test_recompiler.py
+++ b/extra_tests/cffi_tests/cffi1/test_recompiler.py
@@ -2414,6 +2414,18 @@
     assert ffi.sizeof(a[0]) == ffi.sizeof("unsigned")
     assert ffi.sizeof(b[0]) == ffi.sizeof(a[0])
 
+def test_struct_with_func_with_struct_pointer_arg():
+    ffi = FFI()
+    ffi.cdef("""struct BinaryTree {
+            int (* CompareKey)(struct BinaryTree *tree);
+        };""")
+    lib = verify(ffi, "test_struct_with_func_with_struct_pointer_arg", """
+        struct BinaryTree {
+            int (* CompareKey)(struct BinaryTree *tree);
+        };
+    """)
+    ffi.new("struct BinaryTree *")
+
 def test_struct_with_func_with_struct_arg():
     ffi = FFI()
     ffi.cdef("""struct BinaryTree {
diff --git a/extra_tests/test_json.py b/extra_tests/test_json.py
--- a/extra_tests/test_json.py
+++ b/extra_tests/test_json.py
@@ -48,5 +48,10 @@
                  == '{"3": 4, "5": 6}'
 
 def test_boolean_as_dict_key():
+    # In CPython 2.x, dumps({True:...}) gives {"True":...}.  It should be
+    # "true" instead; it's a bug as far as I can tell.  In 3.x it was fixed.
+    # BUT! if we call dumps() with sort_keys=True, then CPython (any version)
+    # gives "true" instead of "True".  Surprize!
+    # I don't want to understand why, let's just not attempt to reproduce that.
     assert json.dumps({True: 5}) == '{"true": 5}'
     assert json.dumps({False: 5}) == '{"false": 5}'
diff --git a/lib_pypy/_cffi_ssl/_cffi_src/build_openssl.py b/lib_pypy/_cffi_ssl/_cffi_src/build_openssl.py
--- a/lib_pypy/_cffi_ssl/_cffi_src/build_openssl.py
+++ b/lib_pypy/_cffi_ssl/_cffi_src/build_openssl.py
@@ -20,7 +20,7 @@
         windows_link_legacy_openssl = os.environ.get(
             "CRYPTOGRAPHY_WINDOWS_LINK_LEGACY_OPENSSL", None
         )
-        if windows_link_legacy_openssl is None:
+        if 0 and windows_link_legacy_openssl is None:
             # Link against the 1.1.0 names
             libs = ["libssl", "libcrypto"]
         else:
diff --git a/pypy/module/_cffi_backend/ctypefunc.py b/pypy/module/_cffi_backend/ctypefunc.py
--- a/pypy/module/_cffi_backend/ctypefunc.py
+++ b/pypy/module/_cffi_backend/ctypefunc.py
@@ -128,6 +128,10 @@
         return W_CTypePtrBase._fget(self, attrchar)
 
     def call(self, funcaddr, args_w):
+        if not funcaddr:
+            raise oefmt(self.space.w_RuntimeError,
+                        "cannot call null function pointer from cdata '%s'",
+                        self.name)
         if self.cif_descr:
             # regular case: this function does not take '...' arguments
             self = jit.promote(self)
diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -4425,3 +4425,10 @@
         float(cast(BBool, 42))
     with pytest.raises(TypeError):
         complex(cast(BBool, 42))
+
+def test_cannot_call_null_function_pointer():
+    BInt = new_primitive_type("int")
+    BFunc = new_function_type((BInt, BInt), BInt, False)
+    f = cast(BFunc, 0)
+    with pytest.raises(RuntimeError):
+        f(40, 2)


More information about the pypy-commit mailing list