]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41172: Fix check for compiler in test suite (GH-21400)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 9 Jul 2020 18:12:07 +0000 (11:12 -0700)
committerGitHub <noreply@github.com>
Thu, 9 Jul 2020 18:12:07 +0000 (11:12 -0700)
(cherry picked from commit af56c4fc76ac39ce76d649d7bebf7f78c1add4fa)

Co-authored-by: Steve Dower <steve.dower@python.org>
Lib/test/support/__init__.py

index 19d52fdfe071a7ddb1015c4d84208bc58912f82b..aee3737ffc4097884ea38e77ef54f5d7228a6583 100644 (file)
@@ -2733,9 +2733,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