[Python-checkins] cpython (merge 3.5 -> default): Issue #25316: distutils raises OSError instead of DistutilsPlatformError when

steve.dower python-checkins at python.org
Mon Oct 5 13:35:44 EDT 2015


https://hg.python.org/cpython/rev/07161dd8a078
changeset: 98543:07161dd8a078
parent: 98541:c0f1f882737c
parent: 98542:a2016b29762c
user: Steve Dower <steve.dower at microsoft.com>
date: Mon Oct 05 10:35:19 2015 -0700
summary:
 Issue #25316: distutils raises OSError instead of DistutilsPlatformError when MSVC is not installed.
files:
 Lib/distutils/_msvccompiler.py | 18 ++++++++++--------
 Misc/NEWS | 3 +++
 2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/Lib/distutils/_msvccompiler.py b/Lib/distutils/_msvccompiler.py
--- a/Lib/distutils/_msvccompiler.py
+++ b/Lib/distutils/_msvccompiler.py
@@ -28,15 +28,17 @@
 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():
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -43,6 +43,9 @@
 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
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /