]> granicus.if.org Git - python/commitdiff
Issue #13979: Fix ctypes.util.find_library ldconfig regex
authorMeador Inge <meadori@gmail.com>
Tue, 14 Feb 2012 04:22:06 +0000 (22:22 -0600)
committerMeador Inge <meadori@gmail.com>
Tue, 14 Feb 2012 04:22:06 +0000 (22:22 -0600)
Lib/ctypes/util.py
Misc/NEWS

index 52b35206145fba877dd3607272759b216bfd39c6..7aee0eff99c72923461c884aed6b368f9fb0ce40 100644 (file)
@@ -182,28 +182,6 @@ elif os.name == "posix":
 
     else:
 
-        def _findLib_ldconfig(name):
-            # XXX assuming GLIBC's ldconfig (with option -p)
-            expr = r'/[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)
-            f = os.popen('LC_ALL=C LANG=C /sbin/ldconfig -p 2>/dev/null')
-            try:
-                data = f.read()
-            finally:
-                f.close()
-            res = re.search(expr, data)
-            if not res:
-                # Hm, this works only for libs needed by the python executable.
-                cmd = 'ldd %s 2>/dev/null' % sys.executable
-                f = os.popen(cmd)
-                try:
-                    data = f.read()
-                finally:
-                    f.close()
-                res = re.search(expr, data)
-                if not res:
-                    return None
-            return res.group(0)
-
         def _findSoname_ldconfig(name):
             import struct
             if struct.calcsize('l') == 4:
@@ -220,8 +198,7 @@ elif os.name == "posix":
             abi_type = mach_map.get(machine, 'libc6')
 
             # XXX assuming GLIBC's ldconfig (with option -p)
-            expr = r'(\S+)\s+\((%s(?:, OS ABI:[^\)]*)?)\)[^/]*(/[^\(\)\s]*lib%s\.[^\(\)\s]*)' \
-                   % (abi_type, re.escape(name))
+            expr = r'\s+(lib%s\.[^\s]+)\s+\(%s' % (re.escape(name), abi_type)
             f = os.popen('/sbin/ldconfig -p 2>/dev/null')
             try:
                 data = f.read()
index ce398633fb0319b8b8c2573995693a68057f2ff8..b8bcc211bf2e8a8595766a07b972258b77078815 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -90,6 +90,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #13979: A bug in ctypes.util.find_library that caused
+  the wrong library name to be returned has been fixed.
+
 - Issue #13993: HTMLParser is now able to handle broken end tags.
 
 - Issue #13960: HTMLParser is now able to handle broken comments.