[Python-checkins] r87978 - in python/branches/py3k: Lib/_pyio.py Misc/NEWS

raymond.hettinger python-checkins at python.org
Thu Jan 13 00:39:32 CET 2011


Author: raymond.hettinger
Date: Thu Jan 13 00:39:31 2011
New Revision: 87978

Log:
Issue #10899: No function type annotations in the standard library.
Removed function type annotations from _pyio.py.



Modified:
   python/branches/py3k/Lib/_pyio.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/_pyio.py
==============================================================================
--- python/branches/py3k/Lib/_pyio.py	(original)
+++ python/branches/py3k/Lib/_pyio.py	Thu Jan 13 00:39:31 2011
@@ -34,9 +34,9 @@
         self.characters_written = characters_written
 
 
-def open(file: (str, bytes), mode: str = "r", buffering: int = -1,
-         encoding: str = None, errors: str = None,
-         newline: str = None, closefd: bool = True) -> "IOBase":
+def open(file, mode = "r", buffering = -1,
+         encoding = None, errors = None,
+         newline = None, closefd = True):
 
     r"""Open file and return a stream.  Raise IOError upon failure.
 
@@ -287,14 +287,14 @@
 
     ### Internal ###
 
-    def _unsupported(self, name: str) -> IOError:
+    def _unsupported(self, name):
         """Internal: raise an exception for unsupported operations."""
         raise UnsupportedOperation("%s.%s() not supported" %
                                    (self.__class__.__name__, name))
 
     ### Positioning ###
 
-    def seek(self, pos: int, whence: int = 0) -> int:
+    def seek(self, pos, whence = 0):
         """Change stream position.
 
         Change the stream position to byte offset offset. offset is
@@ -309,11 +309,11 @@
         """
         self._unsupported("seek")
 
-    def tell(self) -> int:
+    def tell(self):
         """Return current stream position."""
         return self.seek(0, 1)
 
-    def truncate(self, pos: int = None) -> int:
+    def truncate(self, pos = None):
         """Truncate file to size bytes.
 
         Size defaults to the current IO position as reported by tell().  Return
@@ -323,7 +323,7 @@
 
     ### Flush and close ###
 
-    def flush(self) -> None:
+    def flush(self):
         """Flush write buffers, if applicable.
 
         This is not implemented for read-only and non-blocking streams.
@@ -333,7 +333,7 @@
 
     __closed = False
 
-    def close(self) -> None:
+    def close(self):
         """Flush and close the IO object.
 
         This method has no effect if the file is already closed.
@@ -342,7 +342,7 @@
             self.flush()
             self.__closed = True
 
-    def __del__(self) -> None:
+    def __del__(self):
         """Destructor.  Calls close()."""
         # The try/except block is in case this is called at program
         # exit time, when it's possible that globals have already been
@@ -356,7 +356,7 @@
 
     ### Inquiries ###
 
-    def seekable(self) -> bool:
+    def seekable(self):
         """Return whether object supports random access.
 
         If False, seek(), tell() and truncate() will raise UnsupportedOperation.
@@ -371,7 +371,7 @@
             raise UnsupportedOperation("File or stream is not seekable."
                                        if msg is None else msg)
 
-    def readable(self) -> bool:
+    def readable(self):
         """Return whether object was opened for reading.
 
         If False, read() will raise UnsupportedOperation.
@@ -385,7 +385,7 @@
             raise UnsupportedOperation("File or stream is not readable."
                                        if msg is None else msg)
 
-    def writable(self) -> bool:
+    def writable(self):
         """Return whether object was opened for writing.
 
         If False, write() and truncate() will raise UnsupportedOperation.
@@ -416,12 +416,12 @@
 
     ### Context manager ###
 
-    def __enter__(self) -> "IOBase":  # That's a forward reference
+    def __enter__(self):  # That's a forward reference
         """Context management protocol.  Returns self."""
         self._checkClosed()
         return self
 
-    def __exit__(self, *args) -> None:
+    def __exit__(self, *args):
         """Context management protocol.  Calls close()"""
         self.close()
 
@@ -429,14 +429,14 @@
 
     # XXX Should these be present even if unimplemented?
 
-    def fileno(self) -> int:
+    def fileno(self):
         """Returns underlying file descriptor if one exists.
 
         An IOError is raised if the IO object does not use a file descriptor.
         """
         self._unsupported("fileno")
 
-    def isatty(self) -> bool:
+    def isatty(self):
         """Return whether this is an 'interactive' stream.
 
         Return False if it can't be determined.
@@ -446,7 +446,7 @@
 
     ### Readline[s] and writelines ###
 
-    def readline(self, limit: int = -1) -> bytes:
+    def readline(self, limit = -1):
         r"""Read and return a line from the stream.
 
         If limit is specified, at most limit bytes will be read.
@@ -532,7 +532,7 @@
     # primitive operation, but that would lead to nasty recursion in case
     # a subclass doesn't implement either.)
 
-    def read(self, n: int = -1) -> bytes:
+    def read(self, n = -1):
         """Read and return up to n bytes.
 
         Returns an empty bytes object on EOF, or None if the object is
@@ -559,7 +559,7 @@
             res += data
         return bytes(res)
 
-    def readinto(self, b: bytearray) -> int:
+    def readinto(self, b):
         """Read up to len(b) bytes into b.
 
         Returns number of bytes read (0 for EOF), or None if the object
@@ -567,7 +567,7 @@
         """
         self._unsupported("readinto")
 
-    def write(self, b: bytes) -> int:
+    def write(self, b):
         """Write the given buffer to the IO stream.
 
         Returns the number of bytes written, which may be less than len(b).
@@ -596,7 +596,7 @@
     implementation, but wrap one.
     """
 
-    def read(self, n: int = None) -> bytes:
+    def read(self, n = None):
         """Read and return up to n bytes.
 
         If the argument is omitted, None, or negative, reads and
@@ -616,11 +616,11 @@
         """
         self._unsupported("read")
 
-    def read1(self, n: int=None) -> bytes:
+    def read1(self, n = None):
         """Read up to n bytes with at most one read() system call."""
         self._unsupported("read1")
 
-    def readinto(self, b: bytearray) -> int:
+    def readinto(self, b):
         """Read up to len(b) bytes into b.
 
         Like read(), this may issue multiple reads to the underlying raw
@@ -643,7 +643,7 @@
             b[:n] = array.array('b', data)
         return n
 
-    def write(self, b: bytes) -> int:
+    def write(self, b):
         """Write the given buffer to the IO stream.
 
         Return the number of bytes written, which is never less than
@@ -654,7 +654,7 @@
         """
         self._unsupported("write")
 
-    def detach(self) -> None:
+    def detach(self):
         """
         Separate the underlying raw stream from the buffer and return it.
 
@@ -1272,7 +1272,7 @@
     are immutable. There is no public constructor.
     """
 
-    def read(self, n: int = -1) -> str:
+    def read(self, n = -1):
         """Read at most n characters from stream.
 
         Read from underlying buffer until we have n characters or we hit EOF.
@@ -1280,22 +1280,22 @@
         """
         self._unsupported("read")
 
-    def write(self, s: str) -> int:
+    def write(self, s):
         """Write string s to stream."""
         self._unsupported("write")
 
-    def truncate(self, pos: int = None) -> int:
+    def truncate(self, pos = None):
         """Truncate size to pos."""
         self._unsupported("truncate")
 
-    def readline(self) -> str:
+    def readline(self):
         """Read until newline or EOF.
 
         Returns an empty string if EOF is hit immediately.
         """
         self._unsupported("readline")
 
-    def detach(self) -> None:
+    def detach(self):
         """
         Separate the underlying buffer from the TextIOBase and return it.
 

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Thu Jan 13 00:39:31 2011
@@ -43,6 +43,9 @@
 Library
 -------
 
+- Issue #10899: No function type annotations in the standard library.
+  Removed function type annotations from _pyio.py.
+
 - Issue #10875: Update Regular Expression HOWTO; patch by 'SilentGhost'.
 
 - Issue #10872: The repr() of TextIOWrapper objects now includes the mode


More information about the Python-checkins mailing list