]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40459: Fix NameError in platform.py (GH-19855)
authorDennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
Tue, 5 May 2020 02:33:17 +0000 (22:33 -0400)
committerGitHub <noreply@github.com>
Tue, 5 May 2020 02:33:17 +0000 (11:33 +0900)
Lib/platform.py
Misc/NEWS.d/next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst [new file with mode: 0644]

index 3f442ef0fbb65404acf4c86a93232fffe5ce314f..049c2c6ef25a1b02f8bafc8cce53c0305503eaf0 100755 (executable)
@@ -398,9 +398,9 @@ 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
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 (file)
index 0000000..d4bf698
--- /dev/null
@@ -0,0 +1 @@
+:func:`platform.win32_ver` now produces correct *ptype* strings instead of empty strings.