Kaydet (Commit) d78d3b45 authored tarafından Martin v. Löwis's avatar Martin v. Löwis

Fall back to ascii if the locale module cannot be loaded.

üst 10f07c41
...@@ -976,8 +976,13 @@ class TextIOWrapper(TextIOBase): ...@@ -976,8 +976,13 @@ class TextIOWrapper(TextIOBase):
except AttributeError: except AttributeError:
pass pass
if encoding is None: if encoding is None:
import locale try:
encoding = locale.getpreferredencoding() import locale
except ImportError:
# Importing locale may fail if Python is being built
encoding = "ascii"
else:
encoding = locale.getpreferredencoding()
self.buffer = buffer self.buffer = buffer
self._encoding = encoding self._encoding = encoding
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment