]> granicus.if.org Git - python/commitdiff
_pyio: Fix TextIOWrapper constructor: os has no device_encoding() function
authorVictor Stinner <victor.stinner@haypocalc.com>
Tue, 4 May 2010 11:35:36 +0000 (11:35 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Tue, 4 May 2010 11:35:36 +0000 (11:35 +0000)
_io module doesn't call this function which was introduced in Python3.

Lib/_pyio.py

index bdffb124c711ebbecda835d7c6559726a364cb6f..e6911e455b153ccef18ebdfee5abaf1851ff86ff 100644 (file)
@@ -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)