summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/ctypes/util.py13
-rw-r--r--Misc/NEWS3
2 files changed, 8 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)
diff --git a/Misc/NEWS b/Misc/NEWS
index 52ad068..8455c83 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -77,6 +77,9 @@ Core and Builtins
Library
-------
+- Issue #12045: Avoid duplicate execution of command in ctypes.util._get_soname().
+ Patch by Sijin Joseph.
+
- Issue #26960: Backported #16270 from Python 3 to Python 2, to prevent urllib
from hanging when retrieving certain FTP files.