Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 260fbe8

Browse files
committed
Issue #15767: Excise the remaining instances of ModuleNotFoundError
1 parent 3dfd232 commit 260fbe8

8 files changed

Lines changed: 27 additions & 27 deletions

File tree

Lib/stat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,5 @@ def filemode(mode):
151151
# If available, use C implementation
152152
try:
153153
from _stat import *
154-
except ModuleNotFoundError:
154+
except ImportError:
155155
pass

Lib/test/regrtest.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@
146146

147147
try:
148148
import threading
149-
except ModuleNotFoundError:
149+
except ImportError:
150150
threading = None
151151
try:
152152
import multiprocessing.process
153-
except ModuleNotFoundError:
153+
except ImportError:
154154
multiprocessing = None
155155

156156

@@ -180,7 +180,7 @@
180180
if sys.platform == 'darwin':
181181
try:
182182
import resource
183-
except ModuleNotFoundError:
183+
except ImportError:
184184
pass
185185
else:
186186
soft, hard = resource.getrlimit(resource.RLIMIT_STACK)
@@ -567,7 +567,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
567567
if findleaks:
568568
try:
569569
import gc
570-
except ModuleNotFoundError:
570+
except ImportError:
571571
print('No GC available, disabling findleaks.')
572572
findleaks = False
573573
else:
@@ -688,7 +688,7 @@ def test_forever(tests=list(selected)):
688688
if use_mp:
689689
try:
690690
from threading import Thread
691-
except ModuleNotFoundError:
691+
except ImportError:
692692
print("Multiprocess option requires thread support")
693693
sys.exit(2)
694694
from queue import Queue
@@ -1399,7 +1399,7 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
13991399
pic = sys.path_importer_cache.copy()
14001400
try:
14011401
import zipimport
1402-
except ModuleNotFoundError:
1402+
except ImportError:
14031403
zdc = None # Run unmodified on platforms without zipimport support
14041404
else:
14051405
zdc = zipimport._zip_directory_cache.copy()
@@ -1476,7 +1476,7 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
14761476
sys.path_importer_cache.update(pic)
14771477
try:
14781478
import zipimport
1479-
except ModuleNotFoundError:
1479+
except ImportError:
14801480
pass # Run unmodified on platforms without zipimport support
14811481
else:
14821482
zipimport._zip_directory_cache.clear()
@@ -1513,7 +1513,7 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
15131513
doctest.master = None
15141514
try:
15151515
import ctypes
1516-
except ModuleNotFoundError:
1516+
except ImportError:
15171517
# Don't worry about resetting the cache if ctypes is not supported
15181518
pass
15191519
else:

Lib/test/support.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,32 @@
2929

3030
try:
3131
import _thread, threading
32-
except ModuleNotFoundError:
32+
except ImportError:
3333
_thread = None
3434
threading = None
3535
try:
3636
import multiprocessing.process
37-
except ModuleNotFoundError:
37+
except ImportError:
3838
multiprocessing = None
3939

4040
try:
4141
import zlib
42-
except ModuleNotFoundError:
42+
except ImportError:
4343
zlib = None
4444

4545
try:
4646
import gzip
47-
except ModuleNotFoundError:
47+
except ImportError:
4848
gzip = None
4949

5050
try:
5151
import bz2
52-
except ModuleNotFoundError:
52+
except ImportError:
5353
bz2 = None
5454

5555
try:
5656
import lzma
57-
except ModuleNotFoundError:
57+
except ImportError:
5858
lzma = None
5959

6060
__all__ = [
@@ -121,7 +121,7 @@ def import_module(name, deprecated=False, *, required_on=()):
121121
with _ignore_deprecated_imports(deprecated):
122122
try:
123123
return importlib.import_module(name)
124-
except ModuleNotFoundError as msg:
124+
except ImportError as msg:
125125
if sys.platform.startswith(tuple(required_on)):
126126
raise
127127
raise unittest.SkipTest(str(msg))
@@ -193,7 +193,7 @@ def import_fresh_module(name, fresh=(), blocked=(), deprecated=False):
193193
if not _save_and_block_module(blocked_name, orig_modules):
194194
names_to_remove.append(blocked_name)
195195
fresh_module = importlib.import_module(name)
196-
except ModuleNotFoundError:
196+
except ImportError:
197197
fresh_module = None
198198
finally:
199199
for orig_name, module in orig_modules.items():

Lib/test/test___all__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_all(self):
7575
try:
7676
import rlcompleter
7777
import locale
78-
except ModuleNotFoundError:
78+
except ImportError:
7979
pass
8080
else:
8181
locale.setlocale(locale.LC_CTYPE, 'C')

Lib/test/test_tarfile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
# Check for our compression modules.
1313
try:
1414
import gzip
15-
except ModuleNotFoundError:
15+
except ImportError:
1616
gzip = None
1717
try:
1818
import bz2
19-
except ModuleNotFoundError:
19+
except ImportError:
2020
bz2 = None
2121
try:
2222
import lzma
23-
except ModuleNotFoundError:
23+
except ImportError:
2424
lzma = None
2525

2626
def md5sum(data):

Lib/test/test_xmlrpc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515

1616
try:
1717
import gzip
18-
except ModuleNotFoundError:
18+
except ImportError:
1919
gzip = None
2020
try:
2121
import threading
22-
except ModuleNotFoundError:
22+
except ImportError:
2323
threading = None
2424

2525
alist = [{'astring': '[email protected]',

Lib/xmlrpc/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def export_add(self, x, y):
116116
import traceback
117117
try:
118118
import fcntl
119-
except ModuleNotFoundError:
119+
except ImportError:
120120
fcntl = None
121121

122122
def resolve_dotted_attribute(obj, attr, allow_dotted_names=True):

Lib/zipfile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@
1818
try:
1919
import zlib # We may need its compression method
2020
crc32 = zlib.crc32
21-
except ModuleNotFoundError:
21+
except ImportError:
2222
zlib = None
2323
crc32 = binascii.crc32
2424

2525
try:
2626
import bz2 # We may need its compression method
27-
except ModuleNotFoundError:
27+
except ImportError:
2828
bz2 = None
2929

3030
try:
3131
import lzma # We may need its compression method
32-
except ModuleNotFoundError:
32+
except ImportError:
3333
lzma = None
3434

3535
__all__ = ["BadZipFile", "BadZipfile", "error",

0 commit comments

Comments
 (0)