From: Victor Stinner Date: Tue, 4 May 2010 11:35:36 +0000 (+0000) Subject: _pyio: Fix TextIOWrapper constructor: os has no device_encoding() function X-Git-Tag: v2.7b2~93 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=712021991849257ed1162368b0a31bb008412636;p=python _pyio: Fix TextIOWrapper constructor: os has no device_encoding() function _io module doesn't call this function which was introduced in Python3. --- diff --git a/Lib/_pyio.py b/Lib/_pyio.py index bdffb124c7..e6911e455b 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)