summaryrefslogtreecommitdiffstats
path: root/Lib/encodings
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2016-09-07 16:31:52 (GMT)
committerSteve Dower <steve.dower@microsoft.com>2016-09-07 16:31:52 (GMT)
commitfe8f4c9e87699acfd740dfc38ae5320691598250 (patch)
treef911eda95b3418157c21165ec6870b11af8d7a78 /Lib/encodings
parent2f8bfef1587b3e8f43c0ce7cd9546137c5b56782 (diff)
downloadcpython-fe8f4c9e87699acfd740dfc38ae5320691598250.zip
cpython-fe8f4c9e87699acfd740dfc38ae5320691598250.tar.gz
cpython-fe8f4c9e87699acfd740dfc38ae5320691598250.tar.bz2
Issue #27959: Prevent ImportError from escaping codec search function
Diffstat (limited to 'Lib/encodings')
-rw-r--r--Lib/encodings/__init__.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/encodings/__init__.py b/Lib/encodings/__init__.py
index 9a9b90b..ca07881 100644
--- 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
- if encoding == _bootlocale.getpreferredencoding(False):
- import encodings.mbcs
- return encodings.mbcs.getregentry()
+ try:
+ import _bootlocale
+ if encoding == _bootlocale.getpreferredencoding(False):
+ import encodings.mbcs
+ return encodings.mbcs.getregentry()
+ except ImportError:
+ # Imports may fail while we are shutting down
+ pass
codecs.register(_alias_mbcs)