summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2006-07-12 08:43:47 (GMT)
committerThomas Heller <theller@ctypes.org>2006-07-12 08:43:47 (GMT)
commit47d7a069d19fd117d5fc042748536e6cea80bc70 (patch)
tree708d8345cb216bdc7f532efd0497866ec4896706
parenta1f10901097e1a3788314a6aee49edf3690dd0b4 (diff)
downloadcpython-47d7a069d19fd117d5fc042748536e6cea80bc70.zip
cpython-47d7a069d19fd117d5fc042748536e6cea80bc70.tar.gz
cpython-47d7a069d19fd117d5fc042748536e6cea80bc70.tar.bz2
Fix #1467450: ctypes now uses RTLD_GLOBAL by default on OSX 10.3 to
load shared libraries.
-rw-r--r--Lib/ctypes/__init__.py19
-rw-r--r--Misc/NEWS2
2 files changed, 20 insertions, 1 deletions
diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py
index 4987a79..b7d1733 100644
--- a/Lib/ctypes/__init__.py
+++ b/Lib/ctypes/__init__.py
@@ -22,6 +22,23 @@ if __version__ != _ctypes_version:
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 @@ class CDLL(object):
_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)
diff --git a/Misc/NEWS b/Misc/NEWS
index 114664f..a9ef3ee 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -22,6 +22,8 @@ Library
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?
================================