Skip to content

Commit c65ee55

Browse files
bpo-41172: Fix check for compiler in test suite (GH-21400)
(cherry picked from commit af56c4f) Co-authored-by: Steve Dower <[email protected]>
1 parent b4beda1 commit c65ee55

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Lib/test/support/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2733,9 +2733,15 @@ def missing_compiler_executable(cmd_names=[]):
27332733
missing.
27342734
27352735
"""
2736-
from distutils import ccompiler, sysconfig, spawn
2736+
from distutils import ccompiler, sysconfig, spawn, errors
27372737
compiler = ccompiler.new_compiler()
27382738
sysconfig.customize_compiler(compiler)
2739+
if compiler.compiler_type == "msvc":
2740+
# MSVC has no executables, so check whether initialization succeeds
2741+
try:
2742+
compiler.initialize()
2743+
except errors.DistutilsPlatformError:
2744+
return "msvc"
27392745
for name in compiler.executables:
27402746
if cmd_names and name not in cmd_names:
27412747
continue

0 commit comments

Comments
 (0)