mirror of
https://github.com/python/cpython.git
synced 2024-11-24 10:24:35 +08:00
Fall back to ascii if the locale module cannot be loaded.
This commit is contained in:
parent
10f07c41e6
commit
d78d3b4541
@ -976,8 +976,13 @@ class TextIOWrapper(TextIOBase):
|
||||
except AttributeError:
|
||||
pass
|
||||
if encoding is None:
|
||||
import locale
|
||||
encoding = locale.getpreferredencoding()
|
||||
try:
|
||||
import locale
|
||||
except ImportError:
|
||||
# Importing locale may fail if Python is being built
|
||||
encoding = "ascii"
|
||||
else:
|
||||
encoding = locale.getpreferredencoding()
|
||||
|
||||
self.buffer = buffer
|
||||
self._encoding = encoding
|
||||
|
Loading…
Reference in New Issue
Block a user