Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Lib/uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def _netstat_getnode():

def _ipconfig_getnode():
"""Get the hardware address on Windows by running ipconfig.exe."""
import os, re
import os, re, subprocess
first_local_mac = None
dirs = ['', r'c:\windows\system32', r'c:\winnt\system32']
try:
Expand All @@ -480,11 +480,13 @@ def _ipconfig_getnode():
pass
for dir in dirs:
try:
pipe = os.popen(os.path.join(dir, 'ipconfig') + ' /all')
proc = subprocess.Popen([os.path.join(dir, 'ipconfig'), '/all'],
stdout=subprocess.PIPE,
encoding="oem")
except OSError:
continue
with pipe:
for line in pipe:
with proc:
for line in proc.stdout:
value = line.split(':')[-1].strip().lower()
if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value):
mac = int(value.replace('-', ''), 16)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Use the correct encoding for ipconfig output in the uuid module.
Patch by Segev Finer.