mirror of
https://github.com/python/cpython.git
synced 2025-07-12 13:55:34 +00:00
Shift the pipe-using code into an else block, then close the pipe
in finally. Removes two ResourceWarnings.
This commit is contained in:
parent
a277ec4ad9
commit
69cd87b5fa
1 changed files with 7 additions and 4 deletions
11
Lib/uuid.py
11
Lib/uuid.py
|
@ -373,10 +373,13 @@ def _ipconfig_getnode():
|
|||
pipe = os.popen(os.path.join(dir, 'ipconfig') + ' /all')
|
||||
except IOError:
|
||||
continue
|
||||
for line in pipe:
|
||||
value = line.split(':')[-1].strip().lower()
|
||||
if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value):
|
||||
return int(value.replace('-', ''), 16)
|
||||
else:
|
||||
for line in pipe:
|
||||
value = line.split(':')[-1].strip().lower()
|
||||
if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value):
|
||||
return int(value.replace('-', ''), 16)
|
||||
finally:
|
||||
pipe.close()
|
||||
|
||||
def _netbios_getnode():
|
||||
"""Get the hardware address on Windows using NetBIOS calls.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue