Issue #15767: Excise the remaining instances of ModuleNotFoundError
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index bd816dd..aad0c62 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -146,11 +146,11 @@
try:
import threading
-except ModuleNotFoundError:
+except ImportError:
threading = None
try:
import multiprocessing.process
-except ModuleNotFoundError:
+except ImportError:
multiprocessing = None
@@ -180,7 +180,7 @@
if sys.platform == 'darwin':
try:
import resource
- except ModuleNotFoundError:
+ except ImportError:
pass
else:
soft, hard = resource.getrlimit(resource.RLIMIT_STACK)
@@ -567,7 +567,7 @@
if findleaks:
try:
import gc
- except ModuleNotFoundError:
+ except ImportError:
print('No GC available, disabling findleaks.')
findleaks = False
else:
@@ -688,7 +688,7 @@
if use_mp:
try:
from threading import Thread
- except ModuleNotFoundError:
+ except ImportError:
print("Multiprocess option requires thread support")
sys.exit(2)
from queue import Queue
@@ -1399,7 +1399,7 @@
pic = sys.path_importer_cache.copy()
try:
import zipimport
- except ModuleNotFoundError:
+ except ImportError:
zdc = None # Run unmodified on platforms without zipimport support
else:
zdc = zipimport._zip_directory_cache.copy()
@@ -1476,7 +1476,7 @@
sys.path_importer_cache.update(pic)
try:
import zipimport
- except ModuleNotFoundError:
+ except ImportError:
pass # Run unmodified on platforms without zipimport support
else:
zipimport._zip_directory_cache.clear()
@@ -1513,7 +1513,7 @@
doctest.master = None
try:
import ctypes
- except ModuleNotFoundError:
+ except ImportError:
# Don't worry about resetting the cache if ctypes is not supported
pass
else:
diff --git a/Lib/test/support.py b/Lib/test/support.py
index 5b7cfc2..d26e10c 100644
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -29,32 +29,32 @@
try:
import _thread, threading
-except ModuleNotFoundError:
+except ImportError:
_thread = None
threading = None
try:
import multiprocessing.process
-except ModuleNotFoundError:
+except ImportError:
multiprocessing = None
try:
import zlib
-except ModuleNotFoundError:
+except ImportError:
zlib = None
try:
import gzip
-except ModuleNotFoundError:
+except ImportError:
gzip = None
try:
import bz2
-except ModuleNotFoundError:
+except ImportError:
bz2 = None
try:
import lzma
-except ModuleNotFoundError:
+except ImportError:
lzma = None
__all__ = [
@@ -121,7 +121,7 @@
with _ignore_deprecated_imports(deprecated):
try:
return importlib.import_module(name)
- except ModuleNotFoundError as msg:
+ except ImportError as msg:
if sys.platform.startswith(tuple(required_on)):
raise
raise unittest.SkipTest(str(msg))
@@ -193,7 +193,7 @@
if not _save_and_block_module(blocked_name, orig_modules):
names_to_remove.append(blocked_name)
fresh_module = importlib.import_module(name)
- except ModuleNotFoundError:
+ except ImportError:
fresh_module = None
finally:
for orig_name, module in orig_modules.items():
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py
index d0d7fa3..8cc285f 100644
--- a/Lib/test/test___all__.py
+++ b/Lib/test/test___all__.py
@@ -75,7 +75,7 @@
try:
import rlcompleter
import locale
- except ModuleNotFoundError:
+ except ImportError:
pass
else:
locale.setlocale(locale.LC_CTYPE, 'C')
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index f3cb464..2f2bf6b 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -12,15 +12,15 @@
# Check for our compression modules.
try:
import gzip
-except ModuleNotFoundError:
+except ImportError:
gzip = None
try:
import bz2
-except ModuleNotFoundError:
+except ImportError:
bz2 = None
try:
import lzma
-except ModuleNotFoundError:
+except ImportError:
lzma = None
def md5sum(data):
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index 99be297..31d735e 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -15,11 +15,11 @@
try:
import gzip
-except ModuleNotFoundError:
+except ImportError:
gzip = None
try:
import threading
-except ModuleNotFoundError:
+except ImportError:
threading = None
alist = [{'astring': 'foo@bar.baz.spam',