From e71232a175d84e3ec9d41d6e5e5eb12984077b98 Mon Sep 17 00:00:00 2001 From: Chaim Sanders Date: Tue, 18 Oct 2022 17:53:11 -0700 Subject: [PATCH 1/5] gh-98415: Fix UUID ifconfig MAC address detection See #98315 for explanation --- Lib/uuid.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Lib/uuid.py b/Lib/uuid.py index 8fe2479f3f22cf..0fbe95e0d9d3c1 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -371,7 +371,13 @@ 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 + command = (executable,) + if args == ('',): + command = (executable,) + else: + command = (executable,) + args + proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, env=env) @@ -511,7 +517,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.""" From 9af5e8791d81c046062528474639f3280608ac2d Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 19 Oct 2022 01:01:09 +0000 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2022-10-19-01-01-08.gh-issue-98415.ZS2eWh.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2022-10-19-01-01-08.gh-issue-98415.ZS2eWh.rst 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 00000000000000..1e82b0967dcd2c --- /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 UUID on certain OSs . Patch by Chaim Sanders From edbe4c7a6cfd0f5e50457994fe175d59cb4961d3 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Mon, 31 Oct 2022 20:58:32 +0900 Subject: [PATCH 3/5] Apply suggestions from code review --- Lib/uuid.py | 4 +--- .../2022-10-19-01-01-08.gh-issue-98415.ZS2eWh.rst | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/uuid.py b/Lib/uuid.py index 0fbe95e0d9d3c1..d9fe18797c988c 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -373,9 +373,7 @@ def _get_command_stdout(command, *args): env['LC_ALL'] = 'C' # Empty strings will be quoted by popen so we should just ommit it command = (executable,) - if args == ('',): - command = (executable,) - else: + if args != ('',): command = (executable,) + args proc = subprocess.Popen(command, stdout=subprocess.PIPE, 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 index 1e82b0967dcd2c..af2db1f9965cee 100644 --- 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 @@ -1 +1 @@ -Fix detection of MAC addresses for UUID on certain OSs . Patch by Chaim Sanders +Fix detection of MAC addresses for :mod:`uuid` on certain OSs. Patch by Chaim Sanders From 9fb724c95cd83107b13b26346a1b43d402eaf875 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Mon, 31 Oct 2022 21:01:12 +0900 Subject: [PATCH 4/5] Update Lib/uuid.py --- Lib/uuid.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/uuid.py b/Lib/uuid.py index d9fe18797c988c..0dd331fbf9e6e8 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -372,9 +372,10 @@ def _get_command_stdout(command, *args): env = dict(os.environ) env['LC_ALL'] = 'C' # Empty strings will be quoted by popen so we should just ommit it - command = (executable,) if args != ('',): command = (executable,) + args + else: + command = (executable,) proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, From 75b5840f0113070c109e2d17e23ed8f4262fa865 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Wed, 2 Nov 2022 23:57:54 +0900 Subject: [PATCH 5/5] Update Lib/uuid.py --- Lib/uuid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/uuid.py b/Lib/uuid.py index 0dd331fbf9e6e8..e863b631877f6d 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -373,7 +373,7 @@ def _get_command_stdout(command, *args): env['LC_ALL'] = 'C' # Empty strings will be quoted by popen so we should just ommit it if args != ('',): - command = (executable,) + args + command = (executable, *args) else: command = (executable,) proc = subprocess.Popen(command,