summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2013-07-04 17:43:24 -0400
committerBrett Cannon <brett@python.org>2013-07-04 17:43:24 -0400
commit32a9bf9e2e195447cb3d995e9d8778e8a8d5573e (patch)
tree14b04c056dc668f55f33456575bdd13a4c17e86c
parentdc3634843234941af85a87b89458982f131e56a2 (diff)
downloadpython-setuptools-git-32a9bf9e2e195447cb3d995e9d8778e8a8d5573e.tar.gz
Issue #18200: Back out usage of ModuleNotFoundError (8d28d44f3a9a)
-rw-r--r--archive_util.py2
-rw-r--r--ccompiler.py7
-rw-r--r--dist.py9
-rw-r--r--msvccompiler.py4
-rw-r--r--util.py2
5 files changed, 13 insertions, 11 deletions
diff --git a/archive_util.py b/archive_util.py
index ba74045d..fcda08e2 100644
--- a/archive_util.py
+++ b/archive_util.py
@@ -9,7 +9,7 @@ import sys
try:
import zipfile
-except ModuleNotFoundError:
+except ImportError:
zipfile = None
diff --git a/ccompiler.py b/ccompiler.py
index bc183fc5..911e84dd 100644
--- a/ccompiler.py
+++ b/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 @@ def new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0):
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/dist.py b/dist.py
index 11f6ff8f..f7fac089 100644
--- a/dist.py
+++ b/dist.py
@@ -4,11 +4,11 @@ Provides the Distribution class, which represents the module distribution
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 @@ Common commands: (see '--help-commands' for more)
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/msvccompiler.py b/msvccompiler.py
index 9a94b41a..81166569 100644
--- a/msvccompiler.py
+++ b/msvccompiler.py
@@ -28,7 +28,7 @@ try:
RegEnumValue = winreg.EnumValue
RegError = winreg.error
-except ModuleNotFoundError:
+except ImportError:
try:
import win32api
import win32con
@@ -39,7 +39,7 @@ except ModuleNotFoundError:
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/util.py b/util.py
index 257de68e..efb3834c 100644
--- a/util.py
+++ b/util.py
@@ -388,7 +388,7 @@ def byte_compile (py_files,
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)