Issue #18200: Back out usage of ModuleNotFoundError (8d28d44f3a9a)

This commit is contained in:
Brett Cannon 2013-07-04 17:43:24 -04:00
parent fff59155d4
commit cd171c8e92
83 changed files with 158 additions and 144 deletions

View file

@ -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