]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41172: Fix check for compiler in test suite (GH-21400)
authorSteve Dower <steve.dower@python.org>
Thu, 9 Jul 2020 17:52:43 +0000 (18:52 +0100)
committerGitHub <noreply@github.com>
Thu, 9 Jul 2020 17:52:43 +0000 (18:52 +0100)
Lib/test/support/__init__.py

index f8f60fb6c27b912975897c31439f591323cdafa1..b21978a61cd2f12f3f1139447074928aaf544abd 100644 (file)
@@ -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