diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-05-25 16:17:25 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-05-25 16:17:25 (GMT) |
commit | ec62130655fcf10739e1ade7fd492d29bb60c8dc (patch) | |
tree | ee5a5d301575c3ce2240dd64573c84156713e1a2 /Lib/ctypes | |
parent | 12d547a80df9096d16b92a422b655fca7e2a1ef9 (diff) | |
download | cpython-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/ctypes')
-rw-r--r-- | Lib/ctypes/util.py | 13 |
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) |