[pypy-commit] cffi default: Make sure the flags kwarg of verify has no effect on Windows

rguillebert noreply at buildbot.pypy.org
Wed Dec 17 18:12:52 CET 2014


Author: Romain Guillebert <romain.py at gmail.com>
Branch: 
Changeset: r1591:b7065ad45a58
Date: 2014-12-17 17:57 +0100
http://bitbucket.org/cffi/cffi/changeset/b7065ad45a58/

Log:	Make sure the flags kwarg of verify has no effect on Windows

diff --git a/cffi/vengine_cpy.py b/cffi/vengine_cpy.py
--- a/cffi/vengine_cpy.py
+++ b/cffi/vengine_cpy.py
@@ -141,9 +141,10 @@
     def load_library(self, flags=None):
         # XXX review all usages of 'self' here!
         # import it as a new extension module
-        previous_flags = sys.getdlopenflags()
+        if hasattr(sys, "getdlopenflags"):
+            previous_flags = sys.getdlopenflags()
         try:
-            if flags is not None:
+            if hasattr(sys, "setdlopenflags") and flags is not None:
                 sys.setdlopenflags(flags)
             module = imp.load_dynamic(self.verifier.get_module_name(),
                                       self.verifier.modulefilename)
@@ -151,7 +152,8 @@
             error = "importing %r: %s" % (self.verifier.modulefilename, e)
             raise ffiplatform.VerificationError(error)
         finally:
-            sys.setdlopenflags(previous_flags)
+            if hasattr(sys, "setdlopenflags"):
+                sys.setdlopenflags(previous_flags)
         #
         # call loading_cpy_struct() to get the struct layout inferred by
         # the C compiler


More information about the pypy-commit mailing list