10000 gh-98415: Fix uuid.getnode() ifconfig implementation (GH-98423) · miss-islington/cpython@48af207 · GitHub
[go: up one dir, main page]

Skip to content

Commit 48af207

Browse files
csanders-gitcorona10
authored andcommitted
pythongh-98415: Fix uuid.getnode() ifconfig implementation (pythonGH-98423)
The uuid.getnode() function has multiple implementations, tested sequentially. The ifconfig implementation was incorrect and always failed: fix it. In practice, functions of libuuid library are preferred, if available: uuid_generate_time_safe(), uuid_create() or uuid_generate_time(). (cherry picked from commit e3ec272) Co-authored-by: Chaim Sanders <csanders-git@users.noreply.github.com> Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
1 parent e07086d commit 48af207

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Lib/uuid.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,12 @@ def _get_command_stdout(command, *args):
370370
# for are actually localized, but in theory some system could do so.)
371371
env = dict(os.environ)
372372
env['LC_ALL'] = 'C'
373-
proc = subprocess.Popen((executable,) + args,
373+
# Empty strings will be quoted by popen so we should just ommit it
374+
if args != ('',):
375+
command = (executable, *args)
376+
else:
377+
command = (executable,)
378+
proc = subprocess.Popen(command,
374379
stdout=subprocess.PIPE,
375380
stderr=subprocess.DEVNULL,
376381
env=env)
@@ -510,7 +515,7 @@ def _ifconfig_getnode():
510515
mac = _find_mac_near_keyword('ifconfig', args, keywords, lambda i: i+1)
511516
if mac:
512517
return mac
513-
return None
518+
return None
514519

515520
def _ip_getnode():
516521
"""Get the hardware address on Unix by running ip."""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix detection of MAC addresses for :mod:`uuid` on certain OSs. Patch by Chaim Sanders

0 commit comments

Comments
 (0)
0