From: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com> Date: Tue, 5 May 2020 02:33:17 +0000 (-0400) Subject: bpo-40459: Fix NameError in platform.py (GH-19855) X-Git-Tag: v3.9.0b1~179 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1e7e4519a8ddc2239101a0146d788c9161143a77;p=thirdparty%2FPython%2Fcpython.git bpo-40459: Fix NameError in platform.py (GH-19855) --- diff --git a/Lib/platform.py b/Lib/platform.py index 3f442ef0fbb6..049c2c6ef25a 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -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 index 000000000000..d4bf6987fa26 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst @@ -0,0 +1 @@ +:func:`platform.win32_ver` now produces correct *ptype* strings instead of empty strings.