Skip to content

Commit cd171c8

Browse files
committed
Issue #18200: Back out usage of ModuleNotFoundError (8d28d44f3a9a)
1 parent fff5915 commit cd171c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+158
-144
lines changed

Lib/_dummy_thread.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
try:
99
import _thread
10-
except ModuleNotFoundError:
10+
except ImportError:
1111
import _dummy_thread as _thread
1212
1313
"""

Lib/_osx_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def _read_output(commandstring):
6262
try:
6363
import tempfile
6464
fp = tempfile.NamedTemporaryFile()
65-
except ModuleNotFoundError:
65+
except ImportError:
6666
fp = open("/tmp/_osx_support.%s"%(
6767
os.getpid(),), "w+b")
6868

Lib/_pyio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# Import _thread instead of threading to reduce startup cost
1010
try:
1111
from _thread import allocate_lock as Lock
12-
except ModuleNotFoundError:
12+
except ImportError:
1313
from _dummy_thread import allocate_lock as Lock
1414

1515
import io
@@ -1486,7 +1486,7 @@ def __init__(self, buffer, encoding=None, errors=None, newline=None,
14861486
if encoding is None:
14871487
try:
14881488
import locale
1489-
except ModuleNotFoundError:
1489+
except ImportError:
14901490
# Importing locale may fail if Python is being built
14911491
encoding = "ascii"
14921492
else:

Lib/_strptime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
timezone as datetime_timezone)
2222
try:
2323
from _thread import allocate_lock as _thread_allocate_lock
24-
except ModuleNotFoundError:
24+
except ImportError:
2525
from _dummy_thread import allocate_lock as _thread_allocate_lock
2626

2727
__all__ = []

Lib/bisect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,5 @@ def bisect_left(a, x, lo=0, hi=None):
8888
# Overwrite above definitions with a fast C implementation
8989
try:
9090
from _bisect import *
91-
except ModuleNotFoundError:
91+
except ImportError:
9292
pass

Lib/bz2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
try:
1616
from threading import RLock
17-
except ModuleNotFoundError:
17+
except ImportError:
1818
from dummy_threading import RLock
1919

2020
from _bz2 import BZ2Compressor, BZ2Decompressor

Lib/cmd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def cmdloop(self, intro=None):
109109
self.old_completer = readline.get_completer()
110110
readline.set_completer(self.complete)
111111
readline.parse_and_bind(self.completekey+": complete")
112-
except ModuleNotFoundError:
112+
except ImportError:
113113
pass
114114
try:
115115
if intro is not None:
@@ -143,7 +143,7 @@ def cmdloop(self, intro=None):
143143
try:
144144
import readline
145145
readline.set_completer(self.old_completer)
146-
except ModuleNotFoundError:
146+
except ImportError:
147147
pass
148148

149149

Lib/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def interact(banner=None, readfunc=None, local=None):
293293
else:
294294
try:
295295
import readline
296-
except ModuleNotFoundError:
296+
except ImportError:
297297
pass
298298
console.interact(banner)
299299

Lib/collections/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ def _count_elements(mapping, iterable):
395395

396396
try: # Load C helper function if available
397397
from _collections import _count_elements
398-
except ModuleNotFoundError:
398+
except ImportError:
399399
pass
400400

401401
class Counter(dict):

Lib/copy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Error(Exception):
5959

6060
try:
6161
from org.python.core import PyStringMap
62-
except ModuleNotFoundError:
62+
except ImportError:
6363
PyStringMap = None
6464

6565
__all__ = ["Error", "copy", "deepcopy"]

0 commit comments

Comments
 (0)