summaryrefslogtreecommitdiffstats
path: root/Lib/ctypes/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/ctypes/util.py')
-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)