Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c70386e

Browse files
Issue #22131: Fixed a bug in handling an error occured during reading from
a pipe in _ipconfig_getnode().
1 parent f54c350 commit c70386e

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

Lib/uuid.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,13 +383,11 @@ def _ipconfig_getnode():
383383
pipe = os.popen(os.path.join(dir, 'ipconfig') + ' /all')
384384
except OSError:
385385
continue
386-
else:
386+
with pipe:
387387
for line in pipe:
388388
value = line.split(':')[-1].strip().lower()
389389
if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value):
390390
return int(value.replace('-', ''), 16)
391-
finally:
392-
pipe.close()
393391

394392
def _netbios_getnode():
395393
"""Get the hardware address on Windows using NetBIOS calls.

0 commit comments

Comments
 (0)