[pypy-svn] r49397 - pypy/branch/pypy-interp-file/module/_file

arigo at codespeak.net arigo at codespeak.net
Wed Dec 5 19:24:32 CET 2007

Author: arigo
Date: Wed Dec  5 19:24:31 2007
New Revision: 49397


Modified: pypy/branch/pypy-interp-file/module/_file/app_file.py
--- pypy/branch/pypy-interp-file/module/_file/app_file.py	(original)
+++ pypy/branch/pypy-interp-file/module/_file/app_file.py	Wed Dec  5 19:24:31 2007
@@ -202,7 +202,7 @@
             raise ValueError('I/O operation on closed file')
         return self.stream.tell()
-    def seek(self, offset, whence=0):
+    #def seek(self, offset, whence=0):
         """seek(offset[, whence]) -> None.  Move to new file position.
 Argument offset is a byte count.  Optional argument whence defaults to

Modified: pypy/branch/pypy-interp-file/module/_file/interp_file.py
--- pypy/branch/pypy-interp-file/module/_file/interp_file.py	(original)
+++ pypy/branch/pypy-interp-file/module/_file/interp_file.py	Wed Dec  5 19:24:31 2007
@@ -149,6 +149,9 @@
                 size -= len(line)
         return result
+    def direct_seek(self, offset, whence=0):
+        self.getstream().seek(offset, whence)
     def direct_write(self, data):
@@ -240,6 +243,18 @@
 total number of bytes in the lines returned.""",
         wrapresult = "wrap_list_of_str(space, result)")
+    _decl(locals(), "seek", ['self', int, int],
+        """seek(offset[, whence]) -> None.  Move to new file position.
+Argument offset is a byte count.  Optional argument whence defaults to
+0 (offset from start of file, offset should be >= 0); other values are 1
+(move relative to current position, positive or negative), and 2 (move
+relative to end of file, usually negative, although many platforms allow
+seeking beyond the end of a file).  If the file is opened in text mode,
+only offsets returned by tell() are legal.  Use of other offsets causes
+undefined behavior.
+Note that not all file objects are seekable.""")
     _decl(locals(), "write", ['self', str],
         """write(str) -> None.  Write string str to file.

More information about the Pypy-commit mailing list