summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-05-05 02:51:48 (GMT)
committerGitHub <noreply@github.com>2020-05-05 02:51:48 (GMT)
commitefc782d29e229924076ffb6645a72f26242fb3ef (patch)
tree491ca9834986418427c1085ffb0703e8ccf482d3
parent70fe95cdc9ac1b00d4f86b7525dca80caf7003e1 (diff)
downloadcpython-efc782d29e229924076ffb6645a72f26242fb3ef.zip
cpython-efc782d29e229924076ffb6645a72f26242fb3ef.tar.gz
cpython-efc782d29e229924076ffb6645a72f26242fb3ef.tar.bz2
bpo-40459: Fix NameError in platform.py (GH-19855)
(cherry picked from commit 1e7e4519a8ddc2239101a0146d788c9161143a77) Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
-rwxr-xr-xLib/platform.py6
-rw-r--r--Misc/NEWS.d/next/Library/2020-05-02-04-29-31.bpo-40459.fSAYVD.rst1
2 files changed, 4 insertions, 3 deletions
diff --git a/Lib/platform.py b/Lib/platform.py
index 6fbb7b0..994d892 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -395,9 +395,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 0000000..d4bf698
--- /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.