summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-05-04 11:35:36 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-05-04 11:35:36 (GMT)
commit712021991849257ed1162368b0a31bb008412636 (patch)
tree4431853dbba42a2d4012bc8c837972eabea8c091
parent268e4872d3d16ef0457487e401e253d37748c136 (diff)
downloadcpython-712021991849257ed1162368b0a31bb008412636.zip
cpython-712021991849257ed1162368b0a31bb008412636.tar.gz
cpython-712021991849257ed1162368b0a31bb008412636.tar.bz2
_pyio: Fix TextIOWrapper constructor: os has no device_encoding() function
_io module doesn't call this function which was introduced in Python3.
-rw-r--r--Lib/_pyio.py17
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)