]> granicus.if.org Git - python/commitdiff
Issue #12045: Avoid duplicate execution of command in ctypes.util._get_soname().
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 25 May 2011 16:17:25 +0000 (18:17 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 25 May 2011 16:17:25 +0000 (18:17 +0200)
Patch by Sijin Joseph.

Lib/ctypes/util.py
Misc/NEWS

index c437ed35e89164bc836fac8f14d6d633afab8534..929a29c46091fe71f67c05d72cf16944c3e28c80 100644 (file)
@@ -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)
index 52ad068c34eaf482c54b7ace33c5a7043197045b..8455c83bcb2cc4c3765e7857daa81f98bdf68100 100644 (file)
--- 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.