From 833e30a38bb908c69b19a329e303a72c3eb0ce61 Mon Sep 17 00:00:00 2001 From: sweeneyde Date: Sat, 2 May 2020 00:24:25 -0400 Subject: [PATCH 1/7] Fix NameError in platform.py --- Lib/platform.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Lib/platform.py b/Lib/platform.py index 3f442ef0fbb654..09adfe308ddbdd 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -398,11 +398,12 @@ def win32_ver(release='', version='', csd='', ptype=''): else: try: cvkey = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion' - with winreg.OpenKeyEx(HKEY_LOCAL_MACHINE, cvkey) as key: - ptype = QueryValueEx(key, 'CurrentType')[0] - except: + with winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, cvkey) as key: + ptype = winreg.QueryValueEx(key, 'CurrentType')[0] + except OSError: pass + return release, version, csd, ptype From 4357154d72675054eb3c43cb5885fb6144751b6d Mon Sep 17 00:00:00 2001 From: sweeneyde Date: Sat, 2 May 2020 00:26:14 -0400 Subject: [PATCH 2/7] undo addition of blank line --- Lib/platform.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/platform.py b/Lib/platform.py index 09adfe308ddbdd..049c2c6ef25a1b 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -403,7 +403,6 @@ def win32_ver(release='', version='', csd='', ptype=''): except OSError: pass - return release, version, csd, ptype From a09be2578b47ae0f0867d543f6ca1a73a8454f48 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 2 May 2020 04:29:32 +0000 Subject: [PATCH 3/7] =?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 --- .../NEWS.d/next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst diff --git a/Misc/NEWS.d/next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst b/Misc/NEWS.d/next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst new file mode 100644 index 00000000000000..6f03b2945a62c4 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst @@ -0,0 +1 @@ +Fix undefined HKEY_LOCAL_MACHINE name in platform.py \ No newline at end of file From 3003dd42546232520657eddc7c0a05d7cb8d15a8 Mon Sep 17 00:00:00 2001 From: sweeneyde Date: Sat, 2 May 2020 15:19:56 -0400 Subject: [PATCH 4/7] Don't change exception handling --- Lib/platform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/platform.py b/Lib/platform.py index 049c2c6ef25a1b..10ce7075f58694 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -400,7 +400,7 @@ def win32_ver(release='', version='', csd='', ptype=''): cvkey = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion' with winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, cvkey) as key: ptype = winreg.QueryValueEx(key, 'CurrentType')[0] - except OSError: + except: pass return release, version, csd, ptype From 29143c0ada5e89646bd3bbe87815c0639bf177ce Mon Sep 17 00:00:00 2001 From: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com> Date: Sat, 2 May 2020 23:30:34 -0400 Subject: [PATCH 5/7] Better NEWS entry Co-authored-by: Dong-hee Na --- .../next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst b/Misc/NEWS.d/next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst index 6f03b2945a62c4..b34fabba767811 100644 --- a/Misc/NEWS.d/next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst +++ b/Misc/NEWS.d/next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst @@ -1 +1 @@ -Fix undefined HKEY_LOCAL_MACHINE name in platform.py \ No newline at end of file +Fix :exc:`NameError` caused from :func:`platform.win32_ver`. From 944a3b51c8aa7666ba6a1c7e6b05c698cfeaca24 Mon Sep 17 00:00:00 2001 From: sweeneyde Date: Mon, 4 May 2020 17:21:58 -0400 Subject: [PATCH 6/7] put user-facing info in NEWS --- .../next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst b/Misc/NEWS.d/next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst index b34fabba767811..d4bf6987fa2609 100644 --- a/Misc/NEWS.d/next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst +++ b/Misc/NEWS.d/next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst @@ -1 +1 @@ -Fix :exc:`NameError` caused from :func:`platform.win32_ver`. +:func:`platform.win32_ver` now produces correct *ptype* strings instead of empty strings. From 694fa075a4c11300db67d80b00ee27c93865a2dd Mon Sep 17 00:00:00 2001 From: sweeneyde Date: Mon, 4 May 2020 17:24:49 -0400 Subject: [PATCH 7/7] Fix bare except --- Lib/platform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/platform.py b/Lib/platform.py index 10ce7075f58694..049c2c6ef25a1b 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -400,7 +400,7 @@ def win32_ver(release='', version='', csd='', ptype=''): cvkey = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion' with winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, cvkey) as key: ptype = winreg.QueryValueEx(key, 'CurrentType')[0] - except: + except OSError: pass return release, version, csd, ptype