From: Steve Dower Date: Fri, 9 Sep 2016 15:56:37 +0000 (-0700) Subject: Revert #27959: ImportError within an encoding module should also skip the encoding X-Git-Tag: v3.6.0b1~216 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18591e418915aad9811dc1c7a064ca244fcc7f68;p=python Revert #27959: ImportError within an encoding module should also skip the encoding --- diff --git a/Lib/encodings/__init__.py b/Lib/encodings/__init__.py index cf90568605..aa2fb7c2b9 100644 --- a/Lib/encodings/__init__.py +++ b/Lib/encodings/__init__.py @@ -98,9 +98,10 @@ def search_function(encoding): # module with side-effects that is not in the 'encodings' package. mod = __import__('encodings.' + modname, fromlist=_import_tail, level=0) - except ModuleNotFoundError as ex: - if ex.name != 'encodings.' + modname: - raise + except ImportError: + # ImportError may occur because 'encodings.(modname)' does not exist, + # or because it imports a name that does not exist (see mbcs and oem) + pass else: break else: