File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -132,8 +132,10 @@ def _get_soname(f):
132132 cmd = 'if ! type objdump >/dev/null 2>&1; then exit 10; fi;' \
133133 "objdump -p -j .dynamic 2>/dev/null " + f
134134 f = os .popen (cmd )
135- dump = f .read ()
136- rv = f .close ()
135+ try :
136+ dump = f .read ()
137+ finally :
138+ rv = f .close ()
137139 if rv == 10 :
138140 raise OSError ('objdump command not found' )
139141 res = re .search (r'\sSONAME\s+([^\s]+)' , dump )
@@ -176,10 +178,11 @@ def _findLib_crle(name, is64):
176178 else :
177179 cmd = 'env LC_ALL=C /usr/bin/crle 2>/dev/null'
178180
179- for line in os .popen (cmd ).readlines ():
180- line = line .strip ()
181- if line .startswith ('Default Library Path (ELF):' ):
182- paths = line .split ()[4 ]
181+ with contextlib .closing (os .popen (cmd )) as f :
182+ for line in f .readlines ():
183+ line = line .strip ()
184+ if line .startswith ('Default Library Path (ELF):' ):
185+ paths = line .split ()[4 ]
183186
184187 if not paths :
185188 return None
You can’t perform that action at this time.
0 commit comments