mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
gh-98415: Fix uuid.getnode() ifconfig implementation (GH-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 e3ec272f57
)
Co-authored-by: Chaim Sanders <csanders-git@users.noreply.github.com>
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
This commit is contained in:
parent
46ccb35a40
commit
04ab357431
2 changed files with 8 additions and 2 deletions
|
@ -371,7 +371,12 @@ def _get_command_stdout(command, *args):
|
||||||
# for are actually localized, but in theory some system could do so.)
|
# for are actually localized, but in theory some system could do so.)
|
||||||
env = dict(os.environ)
|
env = dict(os.environ)
|
||||||
env['LC_ALL'] = 'C'
|
env['LC_ALL'] = 'C'
|
||||||
proc = subprocess.Popen((executable,) + args,
|
# Empty strings will be quoted by popen so we should just ommit it
|
||||||
|
if args != ('',):
|
||||||
|
command = (executable, *args)
|
||||||
|
else:
|
||||||
|
command = (executable,)
|
||||||
|
proc = subprocess.Popen(command,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.DEVNULL,
|
stderr=subprocess.DEVNULL,
|
||||||
env=env)
|
env=env)
|
||||||
|
@ -511,7 +516,7 @@ def _ifconfig_getnode():
|
||||||
mac = _find_mac_near_keyword('ifconfig', args, keywords, lambda i: i+1)
|
mac = _find_mac_near_keyword('ifconfig', args, keywords, lambda i: i+1)
|
||||||
if mac:
|
if mac:
|
||||||
return mac
|
return mac
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _ip_getnode():
|
def _ip_getnode():
|
||||||
"""Get the hardware address on Unix by running ip."""
|
"""Get the hardware address on Unix by running ip."""
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix detection of MAC addresses for :mod:`uuid` on certain OSs. Patch by Chaim Sanders
|
Loading…
Add table
Add a link
Reference in a new issue