diff options
-rw-r--r-- | Lib/_pyio.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py index bdffb12..e6911e4 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -1438,17 +1438,12 @@ class TextIOWrapper(TextIOBase): raise ValueError("illegal newline value: %r" % (newline,)) if encoding is None: try: - encoding = os.device_encoding(buffer.fileno()) - except (AttributeError, UnsupportedOperation): - pass - if encoding is None: - try: - import locale - except ImportError: - # Importing locale may fail if Python is being built - encoding = "ascii" - else: - encoding = locale.getpreferredencoding() + import locale + except ImportError: + # Importing locale may fail if Python is being built + encoding = "ascii" + else: + encoding = locale.getpreferredencoding() if not isinstance(encoding, basestring): raise ValueError("invalid encoding: %r" % encoding) |