[pypy-commit] pypy default: update to cffi/99940f1f5402

arigo pypy.commits at gmail.com
Fri Mar 9 03:00:33 EST 2018


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r93963:93c05c65dcaa
Date: 2018-03-09 08:54 +0100
http://bitbucket.org/pypy/pypy/changeset/93c05c65dcaa/

Log:	update to cffi/99940f1f5402

diff --git a/pypy/module/_cffi_backend/cdlopen.py b/pypy/module/_cffi_backend/cdlopen.py
--- a/pypy/module/_cffi_backend/cdlopen.py
+++ b/pypy/module/_cffi_backend/cdlopen.py
@@ -53,8 +53,7 @@
         self.libhandle = rffi.cast(DLLHANDLE, 0)
 
         if not libhandle:
-            raise oefmt(self.ffi.w_FFIError, "library '%s' is already closed",
-                        self.libname)
+            return
         self.may_unregister_rpython_finalizer(self.ffi.space)
 
         # Clear the dict to force further accesses to do cdlopen_fetch()
diff --git a/pypy/module/_cffi_backend/libraryobj.py b/pypy/module/_cffi_backend/libraryobj.py
--- a/pypy/module/_cffi_backend/libraryobj.py
+++ b/pypy/module/_cffi_backend/libraryobj.py
@@ -90,7 +90,6 @@
         w_ctype.convert_from_object(rffi.cast(rffi.CCHARP, cdata), w_value)
 
     def close_lib(self):
-        self.check_closed()
         self._finalize_()
 
 
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
@@ -398,6 +398,7 @@
     #
     x.close_lib()
     py.test.raises(ValueError, x.load_function, BVoidP, 'sqrt')
+    x.close_lib()
 
 def test_no_len_on_nonarray():
     p = new_primitive_type("int")
diff --git a/pypy/module/_cffi_backend/test/test_re_python.py b/pypy/module/_cffi_backend/test/test_re_python.py
--- a/pypy/module/_cffi_backend/test/test_re_python.py
+++ b/pypy/module/_cffi_backend/test/test_re_python.py
@@ -114,12 +114,10 @@
         from re_python_pysrc import ffi
         lib = ffi.dlopen(self.extmod)
         ffi.dlclose(lib)
-        e = raises(ffi.error, ffi.dlclose, lib)
-        assert str(e.value) == (
-            "library '%s' is already closed" % (self.extmod,))
         e = raises(ffi.error, getattr, lib, 'add42')
         assert str(e.value) == (
             "library '%s' has been closed" % (self.extmod,))
+        ffi.dlclose(lib)   # does not raise
 
     def test_constant_via_lib(self):
         self.fix_path()
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_function.py b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_function.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_function.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_function.py
@@ -508,9 +508,6 @@
         ffi.cdef("int foobar(void); int foobaz;")
         lib = ffi.dlopen(lib_m)
         ffi.dlclose(lib)
-        e = py.test.raises(ValueError, ffi.dlclose, lib)
-        assert str(e.value).startswith("library '")
-        assert str(e.value).endswith("' has already been closed")
         e = py.test.raises(ValueError, getattr, lib, 'foobar')
         assert str(e.value).startswith("library '")
         assert str(e.value).endswith("' has already been closed")
@@ -520,3 +517,4 @@
         e = py.test.raises(ValueError, setattr, lib, 'foobaz', 42)
         assert str(e.value).startswith("library '")
         assert str(e.value).endswith("' has already been closed")
+        ffi.dlclose(lib)    # does not raise
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_re_python.py b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_re_python.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_re_python.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_re_python.py
@@ -120,12 +120,10 @@
         str_extmod = extmod.encode('utf-8')
     else:
         str_extmod = extmod
-    e = py.test.raises(ffi.error, ffi.dlclose, lib)
-    assert str(e.value).startswith(
-        "library '%s' is already closed" % (str_extmod,))
     e = py.test.raises(ffi.error, getattr, lib, 'add42')
     assert str(e.value) == (
         "library '%s' has been closed" % (str_extmod,))
+    ffi.dlclose(lib)   # does not raise
 
 def test_constant_via_lib():
     from re_python_pysrc import ffi


More information about the pypy-commit mailing list