mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #27959: Prevent ImportError from escaping codec search function
This commit is contained in:
parent
2f8bfef158
commit
fe8f4c9e87
2 changed files with 9 additions and 6 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue