summaryrefslogtreecommitdiffstats
path: root/Lib/uuid.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-02-13 09:15:21 (GMT)
committerGitHub <noreply@github.com>2018-02-13 09:15:21 (GMT)
commitc3f9d7e0ea30e94c901d13e1d43ff0be1e5dbcb7 (patch)
tree1f274db3822eb521aa3d49b22527e8d74a358761 /Lib/uuid.py
parent9fad857444d90b9c6c36c31f5f07e57f390a70f2 (diff)
downloadcpython-c3f9d7e0ea30e94c901d13e1d43ff0be1e5dbcb7.zip
cpython-c3f9d7e0ea30e94c901d13e1d43ff0be1e5dbcb7.tar.gz
cpython-c3f9d7e0ea30e94c901d13e1d43ff0be1e5dbcb7.tar.bz2
[3.6] bpo-32370: Use the correct encoding for ipconfig output in the uuid module. (GH-5608). (#5654)
(cherry picked from commit da6c3da6c33c6bf794f741e348b9c6d86cc43ec5) Co-authored-by: Segev Finer <segev208@gmail.com>
Diffstat (limited to 'Lib/uuid.py')
-rw-r--r--Lib/uuid.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/uuid.py b/Lib/uuid.py
index 3cd67fc..32a48ea 100644
--- a/Lib/uuid.py
+++ b/Lib/uuid.py
@@ -419,7 +419,7 @@ def _netstat_getnode():
def _ipconfig_getnode():
"""Get the hardware address on Windows by running ipconfig.exe."""
- import os, re
+ import os, re, subprocess
dirs = ['', r'c:\windows\system32', r'c:\winnt\system32']
try:
import ctypes
@@ -430,11 +430,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):
return int(value.replace('-', ''), 16)