cpython: 47b4dbd451f5 (original) (raw)
Mercurial > cpython
changeset 103229:47b4dbd451f5
Issue #27959: Prevent ImportError from escaping codec search function [#27959]
Steve Dower steve.dower@microsoft.com | |
---|---|
date | Wed, 07 Sep 2016 09:31:52 -0700 |
parents | f6412378821c |
children | 1b1abe815db0 |
files | Lib/encodings/__init__.py Lib/test/test_io.py |
diffstat | 2 files changed, 9 insertions(+), 6 deletions(-)[+] [-] Lib/encodings/__init__.py 12 Lib/test/test_io.py 3 |
line wrap: on
line diff
--- a/Lib/encodings/init.py +++ b/Lib/encodings/init.py @@ -155,9 +155,13 @@ codecs.register(search_function) if sys.platform == 'win32': def _alias_mbcs(encoding):
import _bootlocale[](#l1.7)
if encoding == _bootlocale.getpreferredencoding(False):[](#l1.8)
import encodings.mbcs[](#l1.9)
return encodings.mbcs.getregentry()[](#l1.10)
try:[](#l1.11)
import _bootlocale[](#l1.12)
if encoding == _bootlocale.getpreferredencoding(False):[](#l1.13)
import encodings.mbcs[](#l1.14)
return encodings.mbcs.getregentry()[](#l1.15)
except ImportError:[](#l1.16)
# Imports may fail while we are shutting down[](#l1.17)
pass[](#l1.18)
--- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -3230,8 +3230,7 @@ def _to_memoryview(buf): class CTextIOWrapperTest(TextIOWrapperTest): io = io
- shutdown_error = ("ImportError: sys.meta_path is None"
if os.name == "nt" else "RuntimeError: could not find io module state")[](#l2.8)
def test_initialization(self): r = self.BytesIO(b"\xc3\xa9\n\n")