Author: Romain Guillebert <[email protected]>
Branch:
Changeset: r1588:2ff481ead26d
Date: 2014-10-21 13:28 +0200
http://bitbucket.org/cffi/cffi/changeset/2ff481ead26d/
Log: Import verify dlopen flags for cpython
diff --git a/cffi/vengine_cpy.py b/cffi/vengine_cpy.py
--- a/cffi/vengine_cpy.py
+++ b/cffi/vengine_cpy.py
@@ -138,15 +138,19 @@
prnt()
prnt('#endif')
- def load_library(self):
+ def load_library(self, flags=0):
# XXX review all usages of 'self' here!
# import it as a new extension module
+ previous_flags = sys.getdlopenflags()
try:
+ sys.setdlopenflags(flags)
module = imp.load_dynamic(self.verifier.get_module_name(),
self.verifier.modulefilename)
except ImportError as e:
error = "importing %r: %s" % (self.verifier.modulefilename, e)
raise ffiplatform.VerificationError(error)
+ finally:
+ sys.setdlopenflags(previous_flags)
#
# call loading_cpy_struct() to get the struct layout inferred by
# the C compiler
diff --git a/testing/test_verify.py b/testing/test_verify.py
--- a/testing/test_verify.py
+++ b/testing/test_verify.py
@@ -1965,14 +1965,18 @@
def test_verify_dlopen_flags():
ffi1 = FFI()
- ffi2 = FFI()
+ ffi1.cdef("int foo;")
- ffi1.cdef("int foo;")
- ffi2.cdef("int foo;")
-
- lib1 = ffi1.verify("int foo;", modulename="foo1", flags=ffi1.RTLD_GLOBAL)
- lib2 = ffi2.verify("int foo;", modulename="foo2", flags=ffi2.RTLD_GLOBAL)
+ lib1 = ffi1.verify("int foo;", flags=ffi1.RTLD_GLOBAL | ffi1.RTLD_LAZY)
+ lib2 = get_second_lib()
lib1.foo = 42
assert lib2.foo == 42
+
+def get_second_lib():
+ # Hack, using modulename makes the test fail
+ ffi2 = FFI()
+ ffi2.cdef("int foo;")
+ lib2 = ffi2.verify("int foo;", flags=ffi2.RTLD_GLOBAL | ffi2.RTLD_LAZY)
+ return lib2
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit