cpython: ac362fb3b86b (original) (raw)
Mercurial > cpython
changeset 74930:ac362fb3b86b 3.2
Issue #13979: Fix ctypes.util.find_library ldconfig regex [#13979]
Meador Inge meadori@gmail.com | |
---|---|
date | Mon, 13 Feb 2012 22:08:39 -0600 |
parents | d8904aff9442 |
children | 096e856a01aa a7f1ffd741d6 |
files | Lib/ctypes/util.py Misc/NEWS |
diffstat | 2 files changed, 4 insertions(+), 18 deletions(-)[+] [-] Lib/ctypes/util.py 19 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py @@ -171,22 +171,6 @@ elif os.name == "posix": else:
def _findLib_ldconfig(name):[](#l1.7)
# XXX assuming GLIBC's ldconfig (with option -p)[](#l1.8)
expr = r'/[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)[](#l1.9)
with contextlib.closing(os.popen('/sbin/ldconfig -p 2>/dev/null')) as f:[](#l1.10)
data = f.read()[](#l1.11)
res = re.search(expr, data)[](#l1.12)
if not res:[](#l1.13)
# Hm, this works only for libs needed by the python executable.[](#l1.14)
cmd = 'ldd %s 2>/dev/null' % sys.executable[](#l1.15)
with contextlib.closing(os.popen(cmd)) as f:[](#l1.16)
data = f.read()[](#l1.17)
res = re.search(expr, data)[](#l1.18)
if not res:[](#l1.19)
return None[](#l1.20)
return res.group(0)[](#l1.21)
- def _findSoname_ldconfig(name): import struct if struct.calcsize('l') == 4: @@ -203,8 +187,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]*)' \[](#l1.30)
% (abi_type, re.escape(name))[](#l1.31)
expr = r'\s+(lib%s\.[^\s]+)\s+\(%s' % (re.escape(name), abi_type)[](#l1.32) with contextlib.closing(os.popen('LC_ALL=C LANG=C /sbin/ldconfig -p 2>/dev/null')) as f:[](#l1.33) data = f.read()[](#l1.34) res = re.search(expr, data)[](#l1.35)
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -113,6 +113,9 @@ Core and Builtins Library ------- +- Issue #13979: A bug in ctypes.util.find_library that caused