]> granicus.if.org Git - python/commitdiff
Issue #25316: distutils raises OSError instead of DistutilsPlatformError when MSVC...
authorSteve Dower <steve.dower@microsoft.com>
Mon, 5 Oct 2015 17:35:00 +0000 (10:35 -0700)
committerSteve Dower <steve.dower@microsoft.com>
Mon, 5 Oct 2015 17:35:00 +0000 (10:35 -0700)
Lib/distutils/_msvccompiler.py
Misc/NEWS

index 03a5f10ee782842fb571e2b45857c1408eaa9c29..10a9ffda24a2b72490d1fd50b9f8d498e3326c83 100644 (file)
@@ -28,15 +28,17 @@ import winreg
 from itertools import count
 
 def _find_vcvarsall(plat_spec):
-    with winreg.OpenKeyEx(
-        winreg.HKEY_LOCAL_MACHINE,
-        r"Software\Microsoft\VisualStudio\SxS\VC7",
-        access=winreg.KEY_READ | winreg.KEY_WOW64_32KEY
-    ) as key:
-        if not key:
-            log.debug("Visual C++ is not registered")
-            return None, None
+    try:
+        key = winreg.OpenKeyEx(
+            winreg.HKEY_LOCAL_MACHINE,
+            r"Software\Microsoft\VisualStudio\SxS\VC7",
+            access=winreg.KEY_READ | winreg.KEY_WOW64_32KEY
+        )
+    except OSError:
+        log.debug("Visual C++ is not registered")
+        return None, None
 
+    with key:
         best_version = 0
         best_dir = None
         for i in count():
index 778ab895501045fbf7a7ae78c10f229f0d59b99e..2c1a7c2136cbd7267c3e198a6b370d4150ac9647 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -34,6 +34,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #25316: distutils raises OSError instead of DistutilsPlatformError
+  when MSVC is not installed.
+
 - Issue #23972: Updates asyncio datagram create method allowing reuseport
   and reuseaddr socket options to be set prior to binding the socket.
   Mirroring the existing asyncio create_server method the reuseaddr option