summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-05-25 16:17:25 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-05-25 16:17:25 (GMT)
commitec62130655fcf10739e1ade7fd492d29bb60c8dc (patch)
treeee5a5d301575c3ce2240dd64573c84156713e1a2 /Lib
parent12d547a80df9096d16b92a422b655fca7e2a1ef9 (diff)
downloadcpython-ec62130655fcf10739e1ade7fd492d29bb60c8dc.zip
cpython-ec62130655fcf10739e1ade7fd492d29bb60c8dc.tar.gz
cpython-ec62130655fcf10739e1ade7fd492d29bb60c8dc.tar.bz2
Issue #12045: Avoid duplicate execution of command in ctypes.util._get_soname().
Patch by Sijin Joseph.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ctypes/util.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
index c437ed3..929a29c 100644
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -137,16 +137,13 @@ elif os.name == "posix":
cmd = 'if ! type objdump >/dev/null 2>&1; then exit 10; fi;' \
"objdump -p -j .dynamic 2>/dev/null " + f
f = os.popen(cmd)
- dump = f.read()
- rv = f.close()
- if rv == 10:
- raise OSError, 'objdump command not found'
- f = os.popen(cmd)
try:
- data = f.read()
+ dump = f.read()
finally:
- f.close()
- res = re.search(r'\sSONAME\s+([^\s]+)', data)
+ rv = f.close()
+ if rv == 10:
+ raise OSError, 'objdump command not found'
+ res = re.search(r'\sSONAME\s+([^\s]+)', dump)
if not res:
return None
return res.group(1)