diff options
Diffstat (limited to 'Lib/io.py')
-rw-r--r-- | Lib/io.py | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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 |