Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e3ec272

Browse filesBrowse files
gh-98415: Fix uuid.getnode() ifconfig implementation (#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(). Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
1 parent 3d889dc commit e3ec272
Copy full SHA for e3ec272

File tree

Expand file treeCollapse file tree

2 files changed

+8
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-2
lines changed

‎Lib/uuid.py

Copy file name to clipboardExpand all lines: Lib/uuid.py
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,12 @@ def _get_command_stdout(command, *args):
371371
# for are actually localized, but in theory some system could do so.)
372372
env = dict(os.environ)
373373
env['LC_ALL'] = 'C'
374-
proc = subprocess.Popen((executable,) + args,
374+
# Empty strings will be quoted by popen so we should just ommit it
375+
if args != ('',):
376+
command = (executable, *args)
377+
else:
378+
command = (executable,)
379+
proc = subprocess.Popen(command,
375380
stdout=subprocess.PIPE,
376381
stderr=subprocess.DEVNULL,
377382
env=env)
@@ -511,7 +516,7 @@ def _ifconfig_getnode():
511516
mac = _find_mac_near_keyword('ifconfig', args, keywords, lambda i: i+1)
512517
if mac:
513518
return mac
514-
return None
519+
return None
515520

516521
def _ip_getnode():
517522
"""Get the hardware address on Unix by running ip."""
+1Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.