diff -u src/Python-2.7.11/Lib/ctypes/__init__.py python-2.7.11.4/Lib/ctypes/__init__.py --- src/Python-2.7.11/Lib/ctypes/__init__.py 2015-12-05 19:46:56 +0000 +++ python-2.7.11.4/Lib/ctypes/__init__.py 2016-05-10 17:53:12 +0000 @@ -355,6 +355,25 @@ flags |= _FUNCFLAG_USE_ERRNO if use_last_error: flags |= _FUNCFLAG_USE_LASTERROR + if _sys.platform.startswith("aix"): + # adding RTLD_NOW is already 'forced' in Modules/_ctypes/callproc.c + # left here (as a comment) to remind it is required by AIX + from _ctypes import RTLD_NOW + mode |= RTLD_NOW + # If name already ends with the char ')' then find_library pre-processing is assummed + # while name may be NULL (to open PyDLL) need to verify it is non-null + # before doing any string operations + if name and not name.endswith(")"): + import ctypes.aixutil as aix + name = aix.find_library(name) + if name: + self._name = name + # If name ends with the char ')' then make sure it has RTLD_MEMBER in mode + # this is a seperate test because find_library may have been called before CDLL + if name and name.endswith(")"): + from _ctypes import RTLD_MEMBER + # RTLD_MEMBER = 0x00040000 + mode |= RTLD_MEMBER class _FuncPtr(_CFuncPtr): _flags_ = flags Only in python-2.7.11.4/Lib/ctypes: __init__.py.orig Only in python-2.7.11.4/Lib/ctypes: aixutil.py Common subdirectories: src/Python-2.7.11/Lib/ctypes/macholib and python-2.7.11.4/Lib/ctypes/macholib Common subdirectories: src/Python-2.7.11/Lib/ctypes/test and python-2.7.11.4/Lib/ctypes/test diff -u src/Python-2.7.11/Lib/ctypes/util.py python-2.7.11.4/Lib/ctypes/util.py --- src/Python-2.7.11/Lib/ctypes/util.py 2015-12-05 19:46:56 +0000 +++ python-2.7.11.4/Lib/ctypes/util.py 2016-05-10 17:59:56 +0000 @@ -71,7 +71,16 @@ def find_library(name): return name -if os.name == "posix" and sys.platform == "darwin": +if sys.platform.startswith("aix"): + # find .so members in .a files + # using dump loader header information + sys. + import ctypes.aixutil as aix + + def find_library(name): + # print ("aix.find: ", name) + return aix.find_library(name) + +elif os.name == "posix" and sys.platform == "darwin": from ctypes.macholib.dyld import dyld_find as _dyld_find def find_library(name): possible = ['lib%s.dylib' % name, @@ -256,6 +265,13 @@ print find_library("m") print find_library("c") print find_library("bz2") + if sys.platform.startswith("aix"): + # examples of working with AIX and versions, when available + print("aix.find_library(\"libiconv.so\")", find_library("libiconv.so")) + print("aix.find_library(\"libintl.so\")", find_library("libintl.so")) + print("aix.find_library(\"libintl.so.1\")", find_library("libintl.so.1")) + print("aix.find_library(\"libintl.so.2\")", find_library("libintl.so.2"), ":: should be None!") + print("aix.find_library(\"libintl.so.8\")", find_library("libintl.so.8")) # getattr ## print cdll.m @@ -268,7 +284,17 @@ print cdll.LoadLibrary("libSystem.dylib") print cdll.LoadLibrary("System.framework/System") else: - print cdll.LoadLibrary("libm.so") + if sys.platform.startswith("aix"): + # libm does not exist as a shared library on AIX, so it fails here + # while test/test_loading.py captures the error correctly + # the test here did not, so calling for libc.so instead + print(cdll.LoadLibrary("libc.so")) + # This test is because libintl may still be only version .1 + # However, it may be version .8 - the latest of the two is returned + # See find_library() exambles above + print(cdll.LoadLibrary("libintl.so")) + else: + print(cdll.LoadLibrary("libm.so")) print cdll.LoadLibrary("libcrypt.so") print find_library("crypt") Only in python-2.7.11.4/Lib/ctypes: util.py.orig