Issue #18200: Update the stdlib (except tests) to use
ModuleNotFoundError.
diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py
index 911e84d..bc183fc 100644
--- a/Lib/distutils/ccompiler.py
+++ b/Lib/distutils/ccompiler.py
@@ -3,7 +3,7 @@
Contains CCompiler, an abstract base class that defines the interface
for the Distutils compiler abstraction model."""
-import sys, os, re
+import importlib, sys, os, re
from distutils.errors import *
from distutils.spawn import spawn
from distutils.file_util import move_file
@@ -1013,10 +1013,9 @@
try:
module_name = "distutils." + module_name
- __import__ (module_name)
- module = sys.modules[module_name]
+ module = importlib.import_module(module_name)
klass = vars(module)[class_name]
- except ImportError:
+ except ModuleNotFoundError:
raise DistutilsModuleError(
"can't compile C/C++ code: unable to load module '%s'" % \
module_name)