From: Antoine Pitrou Date: Sat, 26 Feb 2011 09:37:45 +0000 (+0000) Subject: Revert r88639 (the optimization changes behaviour and breaks buildbots) X-Git-Tag: v3.3.0a1~3048 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=09c530dfc86a9931fa2477154d50f894ea52b7b5;p=python Revert r88639 (the optimization changes behaviour and breaks buildbots) --- diff --git a/Lib/ctypes/test/test_loading.py b/Lib/ctypes/test/test_loading.py index c6815faaf6..4029b463bc 100644 --- a/Lib/ctypes/test/test_loading.py +++ b/Lib/ctypes/test/test_loading.py @@ -102,12 +102,5 @@ class LoaderTest(unittest.TestCase): # This is the real test: call the function via 'call_function' self.assertEqual(0, call_function(proc, (None,))) - if os.name != "nt": - def test_libc_exists(self): - # A basic test that the libc is found by find_library() - # XXX Can this fail on some non-Windows systems? - self.assertTrue(libc_name) - self.assertTrue(os.path.exists(libc_name)) - if __name__ == "__main__": unittest.main() diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py index 3e8379f2f3..1881e89688 100644 --- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py @@ -203,18 +203,14 @@ elif os.name == "posix": abi_type = mach_map.get(machine, 'libc6') # XXX assuming GLIBC's ldconfig (with option -p) - name = 'lib%s' % name - pat = re.compile('\s*(/[^\(\)\s]*%s\.[^\(\)\s]*)' % re.escape(name)) + expr = r'(\S+)\s+\((%s(?:, OS ABI:[^\)]*)?)\)[^/]*(/[^\(\)\s]*lib%s\.[^\(\)\s]*)' \ + % (abi_type, re.escape(name)) with contextlib.closing(os.popen('LC_ALL=C LANG=C /sbin/ldconfig -p 2>/dev/null')) as f: - for line in f: - if not '=>' in line: - continue - path = line.rsplit('=>', 1)[1] - if not name+'.' in path: - continue - res = pat.search(path) - if res: - return res.group(1) + data = f.read() + res = re.search(expr, data) + if not res: + return None + return res.group(1) def find_library(name): return _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name)) diff --git a/Misc/ACKS b/Misc/ACKS index 20e9b0bd68..8066ebcc16 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -329,7 +329,6 @@ Dag Gruneau Michael Guravage Lars Gustäbel Thomas Güttler -Jonas H. Barry Haddow Paul ten Hagen Rasmus Hahn diff --git a/Misc/NEWS b/Misc/NEWS index 3d0abee2dd..30fa398ab9 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -35,9 +35,6 @@ Core and Builtins Library ------- -- Issue #11258: Speed up ctypes.util.find_library() under Linux a lot. Patch - by Jonas H. - - Issue #11297: Add collections.ChainMap(). - Issue #10755: Add the posix.fdlistdir() function. Patch by Ross Lagerwall.