diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-11-02 19:22:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-02 19:22:19 (GMT) |
commit | c23862fc6c3195eccc3cd71e45d7b336dc0d5d50 (patch) | |
tree | a5ed7fcbe4a0a2d5ccf7c91c8a59d0c56e511ee1 /Lib | |
parent | e07086db03d2dc1cd2e2a24f6c9c0ddd422b4cf0 (diff) | |
download | cpython-c23862fc6c3195eccc3cd71e45d7b336dc0d5d50.zip cpython-c23862fc6c3195eccc3cd71e45d7b336dc0d5d50.tar.gz cpython-c23862fc6c3195eccc3cd71e45d7b336dc0d5d50.tar.bz2 |
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 e3ec272f57c3948834a6159cf2604978d3db67a0)
Co-authored-by: Chaim Sanders <csanders-git@users.noreply.github.com>
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/uuid.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/uuid.py b/Lib/uuid.py index 5ae0a3e..fe9f87b 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -370,7 +370,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) @@ -510,7 +515,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.""" |