Issue #22131: Fixed a bug in handling an error occured during reading from

a pipe in _ipconfig_getnode().
This commit is contained in:
Serhiy Storchaka 2014-09-06 22:17:24 +03:00
parent f54c350160
commit c70386ec16
1 changed files with 1 additions and 3 deletions

View File

@ -383,13 +383,11 @@ def _ipconfig_getnode():
pipe = os.popen(os.path.join(dir, 'ipconfig') + ' /all') pipe = os.popen(os.path.join(dir, 'ipconfig') + ' /all')
except OSError: except OSError:
continue continue
else: with pipe:
for line in pipe: for line in pipe:
value = line.split(':')[-1].strip().lower() value = line.split(':')[-1].strip().lower()
if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value): if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value):
return int(value.replace('-', ''), 16) return int(value.replace('-', ''), 16)
finally:
pipe.close()
def _netbios_getnode(): def _netbios_getnode():
"""Get the hardware address on Windows using NetBIOS calls. """Get the hardware address on Windows using NetBIOS calls.