[Python-checkins] r50601 - in python/trunk: Lib/ctypes/__init__.py Misc/NEWS

thomas.heller python-checkins at python.org
Wed Jul 12 10:43:49 CEST 2006


Author: thomas.heller
Date: Wed Jul 12 10:43:47 2006
New Revision: 50601

Modified:
   python/trunk/Lib/ctypes/__init__.py
   python/trunk/Misc/NEWS
Log:
Fix #1467450: ctypes now uses RTLD_GLOBAL by default on OSX 10.3 to
load shared libraries.


Modified: python/trunk/Lib/ctypes/__init__.py
==============================================================================
--- python/trunk/Lib/ctypes/__init__.py	(original)
+++ python/trunk/Lib/ctypes/__init__.py	Wed Jul 12 10:43:47 2006
@@ -22,6 +22,23 @@
 if _os.name in ("nt", "ce"):
     from _ctypes import FormatError
 
+DEFAULT_MODE = RTLD_LOCAL
+if _os.name == "posix" and _sys.platform == "darwin":
+    import gestalt
+
+    # gestalt.gestalt("sysv") returns the version number of the
+    # currently active system file as BCD.
+    # On OS X 10.4.6 -> 0x1046
+    # On OS X 10.2.8 -> 0x1028
+    # See also http://www.rgaros.nl/gestalt/
+    #
+    # On OS X 10.3, we use RTLD_GLOBAL as default mode
+    # because RTLD_LOCAL does not work at least on some
+    # libraries.
+
+    if gestalt.gestalt("sysv") < 0x1040:
+        DEFAULT_MODE = RTLD_GLOBAL
+
 from _ctypes import FUNCFLAG_CDECL as _FUNCFLAG_CDECL, \
      FUNCFLAG_PYTHONAPI as _FUNCFLAG_PYTHONAPI
 
@@ -284,7 +301,7 @@
         _flags_ = _FUNCFLAG_CDECL
         _restype_ = c_int # default, can be overridden in instances
 
-    def __init__(self, name, mode=RTLD_LOCAL, handle=None):
+    def __init__(self, name, mode=DEFAULT_MODE, handle=None):
         self._name = name
         if handle is None:
             self._handle = _dlopen(self._name, mode)

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Wed Jul 12 10:43:47 2006
@@ -22,6 +22,8 @@
 Extension Modules
 -----------------
 
+- Bug #1467450: On Mac OS X 10.3, RTLD_GLOBAL is now used as the
+  default mode for loading shared libraries in ctypes.
 
 What's New in Python 2.5 beta 2?
 ================================


More information about the Python-checkins mailing list