diff options
author | Chaim Sanders <csanders-git@users.noreply.github.com> | 2022-11-02 18:41:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-02 18:41:20 (GMT) |
commit | e3ec272f57c3948834a6159cf2604978d3db67a0 (patch) | |
tree | f51493a96f08ed69ad6571ea9c35aec27b334ae1 | |
parent | 3d889dc0a0efa6fcbd984ece365c9ac08d2cd4a9 (diff) | |
download | cpython-e3ec272f57c3948834a6159cf2604978d3db67a0.zip cpython-e3ec272f57c3948834a6159cf2604978d3db67a0.tar.gz cpython-e3ec272f57c3948834a6159cf2604978d3db67a0.tar.bz2 |
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>
-rw-r--r-- | Lib/uuid.py | 9 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2022-10-19-01-01-08.gh-issue-98415.ZS2eWh.rst | 1 |
2 files changed, 8 insertions, 2 deletions
diff --git a/Lib/uuid.py b/Lib/uuid.py index 8fe2479..e863b63 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -371,7 +371,12 @@ def _get_command_stdout(command, *args): # for are actually localized, but in theory some system could do so.) env = dict(os.environ) 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, stderr=subprocess.DEVNULL, env=env) @@ -511,7 +516,7 @@ def _ifconfig_getnode(): mac = _find_mac_near_keyword('ifconfig', args, keywords, lambda i: i+1) if mac: return mac - return None + return None def _ip_getnode(): """Get the hardware address on Unix by running ip.""" diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-10-19-01-01-08.gh-issue-98415.ZS2eWh.rst b/Misc/NEWS.d/next/Core and Builtins/2022-10-19-01-01-08.gh-issue-98415.ZS2eWh.rst new file mode 100644 index 0000000..af2db1f --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-10-19-01-01-08.gh-issue-98415.ZS2eWh.rst @@ -0,0 +1 @@ +Fix detection of MAC addresses for :mod:`uuid` on certain OSs. Patch by Chaim Sanders |