[Python-3000-checkins] r55557 - python/branches/py3k-struni/Lib/io.py python/branches/py3k-struni/Lib/site.py

guido.van.rossum python-3000-checkins at python.org
Thu May 24 19:58:13 CEST 2007


Author: guido.van.rossum
Date: Thu May 24 19:58:06 2007
New Revision: 55557

Modified:
   python/branches/py3k-struni/Lib/io.py
   python/branches/py3k-struni/Lib/site.py
Log:
Add an encoding property to TextIOBase instances.
Add sys.__std{in,out,err}__.
Make test_sys pass.


Modified: python/branches/py3k-struni/Lib/io.py
==============================================================================
--- python/branches/py3k-struni/Lib/io.py	(original)
+++ python/branches/py3k-struni/Lib/io.py	Thu May 24 19:58:06 2007
@@ -925,6 +925,11 @@
             raise StopIteration
         return line
 
+    @property
+    def encoding(self):
+        """Subclasses should override."""
+        return None
+
     # The following are provided for backwards compatibility
 
     def readlines(self, hint=None):
@@ -970,6 +975,10 @@
         self._snapshot = None
         self._seekable = self._telling = self.buffer.seekable()
 
+    @property
+    def encoding(self):
+        return self._encoding
+
     # A word about _snapshot.  This attribute is either None, or a
     # tuple (decoder_state, readahead, pending) where decoder_state is
     # the second (integer) item of the decoder state, readahead is the

Modified: python/branches/py3k-struni/Lib/site.py
==============================================================================
--- python/branches/py3k-struni/Lib/site.py	(original)
+++ python/branches/py3k-struni/Lib/site.py	Thu May 24 19:58:06 2007
@@ -411,9 +411,9 @@
         def __new__(cls, *args, **kwds):
             return io.open(*args, **kwds)
     __builtin__.open = open
-    sys.stdin = io.open(0, "r")
-    sys.stdout = io.open(1, "w")
-    sys.stderr = io.open(2, "w")
+    sys.__stdin__ = sys.stdin = io.open(0, "r")
+    sys.__stdout__ = sys.stdout = io.open(1, "w")
+    sys.__stderr__ = sys.stderr = io.open(2, "w")
 
 
 def main():


More information about the Python-3000-checkins mailing list