[Python-checkins] cpython: Revert #27959: ImportError within an encoding module should also skip the

steve.dower python-checkins at python.org
Fri Sep 9 11:57:11 EDT 2016


https://hg.python.org/cpython/rev/4e80a157ea66
changeset:   103400:4e80a157ea66
user:        Steve Dower <steve.dower at microsoft.com>
date:        Fri Sep 09 08:56:37 2016 -0700
summary:
  Revert #27959: ImportError within an encoding module should also skip the encoding

files:
  Lib/encodings/__init__.py |  7 ++++---
  1 files changed, 4 insertions(+), 3 deletions(-)


diff --git a/Lib/encodings/__init__.py b/Lib/encodings/__init__.py
--- a/Lib/encodings/__init__.py
+++ b/Lib/encodings/__init__.py
@@ -98,9 +98,10 @@
             # 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:

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list