diff --git a/Lib/platform.py b/Lib/platform.py index 6ab06b58321e0f..7af46ffd17728a 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -570,9 +570,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 00000000000000..d4bf6987fa2609 --- /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.