mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #18200: Back out usage of ModuleNotFoundError (8d28d44f3a9a)
This commit is contained in:
parent
fff59155d4
commit
cd171c8e92
83 changed files with 158 additions and 144 deletions
|
@ -29,11 +29,11 @@ Written by Marc-Andre Lemburg (mal@lemburg.com).
|
|||
"""#"
|
||||
|
||||
import codecs
|
||||
import importlib
|
||||
from . import aliases
|
||||
|
||||
_cache = {}
|
||||
_unknown = '--unknown--'
|
||||
_import_tail = ['*']
|
||||
_aliases = aliases.aliases
|
||||
|
||||
class CodecRegistryError(LookupError, SystemError):
|
||||
|
@ -94,8 +94,9 @@ def search_function(encoding):
|
|||
try:
|
||||
# Import is absolute to prevent the possibly malicious import of a
|
||||
# module with side-effects that is not in the 'encodings' package.
|
||||
mod = importlib.import_module('encodings.' + modname)
|
||||
except ModuleNotFoundError:
|
||||
mod = __import__('encodings.' + modname, fromlist=_import_tail,
|
||||
level=0)
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
break
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue