diff -ru src/Python-3.5.1/Lib/ctypes/__init__.py python-3.5.1.1/Lib/ctypes/__init__.py --- src/Python-3.5.1/Lib/ctypes/__init__.py 2015-12-07 01:39:07 +0000 +++ python-3.5.1.1/Lib/ctypes/__init__.py 2016-05-10 16:50:31 +0000 @@ -337,6 +337,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-3.5.1.1/Lib/ctypes: __pycache__ Only in python-3.5.1.1/Lib/ctypes: aixutil.py diff -ru src/Python-3.5.1/Lib/ctypes/test/test_loading.py python-3.5.1.1/Lib/ctypes/test/test_loading.py --- src/Python-3.5.1/Lib/ctypes/test/test_loading.py 2015-12-07 01:39:07 +0000 +++ python-3.5.1.1/Lib/ctypes/test/test_loading.py 2016-05-09 12:51:46 +0000 @@ -43,7 +43,7 @@ self.assertRaises(OSError, cdll.LoadLibrary, self.unknowndll) def test_find(self): - for name in ("c", "m"): + for name in ("c", "m", "intl", "ssl"): lib = find_library(name) if lib: cdll.LoadLibrary(lib) diff -ru src/Python-3.5.1/Lib/ctypes/util.py python-3.5.1.1/Lib/ctypes/util.py --- src/Python-3.5.1/Lib/ctypes/util.py 2015-12-07 01:39:07 +0000 +++ python-3.5.1.1/Lib/ctypes/util.py 2016-05-10 14:56:07 +0000 @@ -76,7 +76,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, @@ -253,6 +262,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 @@ -265,7 +281,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"))