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)
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")
+ shutdown_error = "RuntimeError: could not find io module state"
def test_initialization(self):
r = self.BytesIO(b"\xc3\xa9\n\n")