]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40459: Fix NameError in platform.py (GH-19855)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 5 May 2020 02:51:48 +0000 (19:51 -0700)
committerGitHub <noreply@github.com>
Tue, 5 May 2020 02:51:48 +0000 (19:51 -0700)
(cherry picked from commit 1e7e4519a8ddc2239101a0146d788c9161143a77)

Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
Lib/platform.py
Misc/NEWS.d/next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst [new file with mode: 0644]

index 6fbb7b08c598e3d1782479ab492e4d8c964604ef..994d892c5e6166921b05e9aeaee4d95c0a579c7a 100755 (executable)
@@ -395,9 +395,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.