Issue #19734: ctypes resource management fixes
This commit is contained in:
parent
878d258a22
commit
1889623e1a
@ -132,8 +132,10 @@ elif os.name == "posix":
|
|||||||
cmd = 'if ! type objdump >/dev/null 2>&1; then exit 10; fi;' \
|
cmd = 'if ! type objdump >/dev/null 2>&1; then exit 10; fi;' \
|
||||||
"objdump -p -j .dynamic 2>/dev/null " + f
|
"objdump -p -j .dynamic 2>/dev/null " + f
|
||||||
f = os.popen(cmd)
|
f = os.popen(cmd)
|
||||||
dump = f.read()
|
try:
|
||||||
rv = f.close()
|
dump = f.read()
|
||||||
|
finally:
|
||||||
|
rv = f.close()
|
||||||
if rv == 10:
|
if rv == 10:
|
||||||
raise OSError('objdump command not found')
|
raise OSError('objdump command not found')
|
||||||
res = re.search(r'\sSONAME\s+([^\s]+)', dump)
|
res = re.search(r'\sSONAME\s+([^\s]+)', dump)
|
||||||
@ -176,10 +178,11 @@ elif os.name == "posix":
|
|||||||
else:
|
else:
|
||||||
cmd = 'env LC_ALL=C /usr/bin/crle 2>/dev/null'
|
cmd = 'env LC_ALL=C /usr/bin/crle 2>/dev/null'
|
||||||
|
|
||||||
for line in os.popen(cmd).readlines():
|
with contextlib.closing(os.popen(cmd)) as f:
|
||||||
line = line.strip()
|
for line in f.readlines():
|
||||||
if line.startswith('Default Library Path (ELF):'):
|
line = line.strip()
|
||||||
paths = line.split()[4]
|
if line.startswith('Default Library Path (ELF):'):
|
||||||
|
paths = line.split()[4]
|
||||||
|
|
||||||
if not paths:
|
if not paths:
|
||||||
return None
|
return None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user