[Python-checkins] bpo-41172: Fix check for compiler in test suite (GH-21400)

Steve Dower webhook-mailer at python.org
Thu Jul 9 13:52:48 EDT 2020


https://github.com/python/cpython/commit/af56c4fc76ac39ce76d649d7bebf7f78c1add4fa
commit: af56c4fc76ac39ce76d649d7bebf7f78c1add4fa
branch: master
author: Steve Dower <steve.dower at python.org>
committer: GitHub <noreply at github.com>
date: 2020-07-09T18:52:43+01:00
summary:

bpo-41172: Fix check for compiler in test suite (GH-21400)

files:
M Lib/test/support/__init__.py

diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index f8f60fb6c27b9..b21978a61cd2f 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -1673,9 +1673,15 @@ def missing_compiler_executable(cmd_names=[]):
     missing.
 
     """
-    from distutils import ccompiler, sysconfig, spawn
+    from distutils import ccompiler, sysconfig, spawn, errors
     compiler = ccompiler.new_compiler()
     sysconfig.customize_compiler(compiler)
+    if compiler.compiler_type == "msvc":
+        # MSVC has no executables, so check whether initialization succeeds
+        try:
+            compiler.initialize()
+        except errors.DistutilsPlatformError:
+            return "msvc"
     for name in compiler.executables:
         if cmd_names and name not in cmd_names:
             continue



More information about the Python-checkins mailing list