Merged revisions 86009 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r86009 | brian.curtin | 2010-10-30 20:10:58 -0500 (Sat, 30 Oct 2010) | 2 lines Fix ResourceWarning for unclosed files (from os.popen) ........
This commit is contained in:
parent
a813a638ef
commit
0343d8f4f1
10
Lib/uuid.py
10
Lib/uuid.py
|
@ -322,15 +322,15 @@ def _find_mac(command, args, hw_identifiers, get_index):
|
||||||
# LC_ALL to get English output, 2>/dev/null to
|
# LC_ALL to get English output, 2>/dev/null to
|
||||||
# prevent output on stderr
|
# prevent output on stderr
|
||||||
cmd = 'LC_ALL=C %s %s 2>/dev/null' % (executable, args)
|
cmd = 'LC_ALL=C %s %s 2>/dev/null' % (executable, args)
|
||||||
pipe = os.popen(cmd)
|
with os.popen(cmd) as pipe:
|
||||||
except IOError:
|
|
||||||
continue
|
|
||||||
|
|
||||||
for line in pipe:
|
for line in pipe:
|
||||||
words = line.lower().split()
|
words = line.lower().split()
|
||||||
for i in range(len(words)):
|
for i in range(len(words)):
|
||||||
if words[i] in hw_identifiers:
|
if words[i] in hw_identifiers:
|
||||||
return int(words[get_index(i)].replace(':', ''), 16)
|
return int(
|
||||||
|
words[get_index(i)].replace(':', ''), 16)
|
||||||
|
except IOError:
|
||||||
|
continue
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _ifconfig_getnode():
|
def _ifconfig_getnode():
|
||||||
|
|
Loading…
Reference in New Issue