Issue #18200: Back out usage of ModuleNotFoundError (8d28d44f3a9a)
diff --git a/Lib/distutils/archive_util.py b/Lib/distutils/archive_util.py
index ba74045..fcda08e 100644
--- a/Lib/distutils/archive_util.py
+++ b/Lib/distutils/archive_util.py
@@ -9,7 +9,7 @@
 
 try:
     import zipfile
-except ModuleNotFoundError:
+except ImportError:
     zipfile = None
 
 
diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py
index bc183fc..911e84d 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 importlib, sys, os, re
+import sys, os, re
 from distutils.errors import *
 from distutils.spawn import spawn
 from distutils.file_util import move_file
@@ -1013,9 +1013,10 @@
 
     try:
         module_name = "distutils." + module_name
-        module = importlib.import_module(module_name)
+        __import__ (module_name)
+        module = sys.modules[module_name]
         klass = vars(module)[class_name]
-    except ModuleNotFoundError:
+    except ImportError:
         raise DistutilsModuleError(
               "can't compile C/C++ code: unable to load module '%s'" % \
               module_name)
diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py
index 11f6ff8..f7fac08 100644
--- a/Lib/distutils/dist.py
+++ b/Lib/distutils/dist.py
@@ -4,11 +4,11 @@
 being built/installed/distributed.
 """
 
-import importlib, sys, os, re
+import sys, os, re
 
 try:
     import warnings
-except ModuleNotFoundError:
+except ImportError:
     warnings = None
 
 from distutils.errors import *
@@ -788,8 +788,9 @@
             klass_name = command
 
             try:
-                module = importlib.import_module(module_name)
-            except ModuleNotFoundError:
+                __import__ (module_name)
+                module = sys.modules[module_name]
+            except ImportError:
                 continue
 
             try:
diff --git a/Lib/distutils/msvccompiler.py b/Lib/distutils/msvccompiler.py
index 9a94b41..8116656 100644
--- a/Lib/distutils/msvccompiler.py
+++ b/Lib/distutils/msvccompiler.py
@@ -28,7 +28,7 @@
     RegEnumValue = winreg.EnumValue
     RegError = winreg.error
 
-except ModuleNotFoundError:
+except ImportError:
     try:
         import win32api
         import win32con
@@ -39,7 +39,7 @@
         RegEnumKey = win32api.RegEnumKey
         RegEnumValue = win32api.RegEnumValue
         RegError = win32api.error
-    except ModuleNotFoundError:
+    except ImportError:
         log.info("Warning: Can't read registry to find the "
                  "necessary compiler setting\n"
                  "Make sure that Python modules winreg, "
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index 257de68..efb3834 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -388,7 +388,7 @@
         try:
             from tempfile import mkstemp
             (script_fd, script_name) = mkstemp(".py")
-        except ModuleNotFoundError:
+        except ImportError:
             from tempfile import mktemp
             (script_fd, script_name) = None, mktemp(".py")
         log.info("writing byte-compilation script '%s'", script_name)