8000 bpo-40459: Fix NameError in platform.py (GH-19855) · python/cpython@efc782d · GitHub
[go: up one dir, main page]

Skip to content

Commit efc782d

Browse files
bpo-40459: Fix NameError in platform.py (GH-19855)
(cherry picked from commit 1e7e451) Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
1 parent 70fe95c commit efc782d

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
@@ -395,9 +395,9 @@ def win32_ver(release='', version='', csd='', ptype=''):
395395
else:
396396
try:
397397
cvkey = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
398-
with winreg.OpenKeyEx(HKEY_LOCAL_MACHINE, cvkey) as key:
399-
ptype = QueryValueEx(key, 'CurrentType')[0]
400-
except:
398+
with winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, cvkey) as key:
399+
ptype = winreg.QueryValueEx(key, 'CurrentType')[0]
400+
except OSError:
401401
pass
402402

403403
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)
0