Skip to content

Commit 8ddf915

Browse files
bpo-40459: Fix NameError in platform.py (GH-19855)
(cherry picked from commit 1e7e451) Co-authored-by: Dennis Sweeney <[email protected]>
1 parent 4eec39a commit 8ddf915

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Lib/platform.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,9 @@ def win32_ver(release='', version='', csd='', ptype=''):
570570
else:
571571
try:
572572
cvkey = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
573-
with winreg.OpenKeyEx(HKEY_LOCAL_MACHINE, cvkey) as key:
574-
ptype = QueryValueEx(key, 'CurrentType')[0]
575-
except:
573+
with winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, cvkey) as key:
574+
ptype = winreg.QueryValueEx(key, 'CurrentType')[0]
575+
except OSError:
576576
pass
577577

578578
return release, version, csd, ptype
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:func:`platform.win32_ver` now produces correct *ptype* strings instead of empty strings.

0 commit comments

Comments
 (0)