diff options
author | Brett Cannon <brett@python.org> | 2013-06-14 00:57:26 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2013-06-14 00:57:26 (GMT) |
commit | 0a140668faf18bf7f8d2ea15e57da5e2a0625292 (patch) | |
tree | 97522129bc600a6eff09899ae7a177b5f3e980b3 /Lib/distutils | |
parent | 9702a17a6ab90d026449dd20631a6f380d007b3d (diff) | |
download | cpython-0a140668faf18bf7f8d2ea15e57da5e2a0625292.zip cpython-0a140668faf18bf7f8d2ea15e57da5e2a0625292.tar.gz cpython-0a140668faf18bf7f8d2ea15e57da5e2a0625292.tar.bz2 |
Issue #18200: Update the stdlib (except tests) to use
ModuleNotFoundError.
Diffstat (limited to 'Lib/distutils')
-rw-r--r-- | Lib/distutils/archive_util.py | 2 | ||||
-rw-r--r-- | Lib/distutils/ccompiler.py | 7 | ||||
-rw-r--r-- | Lib/distutils/dist.py | 9 | ||||
-rw-r--r-- | Lib/distutils/msvccompiler.py | 4 | ||||
-rw-r--r-- | Lib/distutils/util.py | 2 |
5 files changed, 11 insertions, 13 deletions
diff --git a/Lib/distutils/archive_util.py b/Lib/distutils/archive_util.py index fcda08e..ba74045 100644 --- a/Lib/distutils/archive_util.py +++ b/Lib/distutils/archive_util.py @@ -9,7 +9,7 @@ import sys try: import zipfile -except ImportError: +except ModuleNotFoundError: zipfile = None 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 @@ def new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0): 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) diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py index f7fac08..11f6ff8 100644 --- a/Lib/distutils/dist.py +++ b/Lib/distutils/dist.py @@ -4,11 +4,11 @@ Provides the Distribution class, which represents the module distribution being built/installed/distributed. """ -import sys, os, re +import importlib, sys, os, re try: import warnings -except ImportError: +except ModuleNotFoundError: warnings = None from distutils.errors import * @@ -788,9 +788,8 @@ Common commands: (see '--help-commands' for more) klass_name = command try: - __import__ (module_name) - module = sys.modules[module_name] - except ImportError: + module = importlib.import_module(module_name) + except ModuleNotFoundError: continue try: diff --git a/Lib/distutils/msvccompiler.py b/Lib/distutils/msvccompiler.py index 8116656..9a94b41 100644 --- a/Lib/distutils/msvccompiler.py +++ b/Lib/distutils/msvccompiler.py @@ -28,7 +28,7 @@ try: RegEnumValue = winreg.EnumValue RegError = winreg.error -except ImportError: +except ModuleNotFoundError: try: import win32api import win32con @@ -39,7 +39,7 @@ except ImportError: RegEnumKey = win32api.RegEnumKey RegEnumValue = win32api.RegEnumValue RegError = win32api.error - except ImportError: + except ModuleNotFoundError: 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 a2f9544..e241f59 100644 --- a/Lib/distutils/util.py +++ b/Lib/distutils/util.py @@ -388,7 +388,7 @@ def byte_compile (py_files, try: from tempfile import mkstemp (script_fd, script_name) = mkstemp(".py") - except ImportError: + except ModuleNotFoundError: from tempfile import mktemp (script_fd, script_name) = None, mktemp(".py") log.info("writing byte-compilation script '%s'", script_name) |