Skip to content

Commit 1e7e451

Browse files
authored
bpo-40459: Fix NameError in platform.py (GH-19855)
1 parent 92a98ed commit 1e7e451

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
@@ -398,9 +398,9 @@ def win32_ver(release='', version='', csd='', ptype=''):
398398
else:
399399
try:
400400
cvkey = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
401-
with winreg.OpenKeyEx(HKEY_LOCAL_MACHINE, cvkey) as key:
402-
ptype = QueryValueEx(key, 'CurrentType')[0]
403-
except:
401+
with winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, cvkey) as key:
402+
ptype = winreg.QueryValueEx(key, 'CurrentType')[0]
403+
except OSError:
404404
pass
405405

406406
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)