diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-01-31 22:47:27 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-01-31 22:47:27 (GMT) |
commit | 905a2ffe3e5445925a669ab433521ddb66cf1043 (patch) | |
tree | f3a63e9771498b63eebb2797deaede3577695aaf /Lib/_pyio.py | |
parent | 9b661e6ef636bdd71639befc11e7ce71755f6421 (diff) | |
download | cpython-905a2ffe3e5445925a669ab433521ddb66cf1043.zip cpython-905a2ffe3e5445925a669ab433521ddb66cf1043.tar.gz cpython-905a2ffe3e5445925a669ab433521ddb66cf1043.tar.bz2 |
Merged revisions 77890 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77890 | antoine.pitrou | 2010-01-31 23:26:04 +0100 (dim., 31 janv. 2010) | 7 lines
- Issue #6939: Fix file I/O objects in the `io` module to keep the original
file position when calling `truncate()`. It would previously change the
file position to the given argument, which goes against the tradition of
ftruncate() and other truncation APIs. Patch by Pascal Chambon.
........
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r-- | Lib/_pyio.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py index a4beb2b..8960ce9 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -856,7 +856,7 @@ class BytesIO(BufferedIOBase): elif pos < 0: raise ValueError("negative truncate position %r" % (pos,)) del self._buffer[pos:] - return self.seek(pos) + return pos def readable(self): return True @@ -1215,8 +1215,7 @@ class BufferedRandom(BufferedWriter, BufferedReader): if pos is None: pos = self.tell() # Use seek to flush the read buffer. - self.seek(pos) - return BufferedWriter.truncate(self) + return BufferedWriter.truncate(self, pos) def read(self, n=None): if n is None: @@ -1717,8 +1716,7 @@ class TextIOWrapper(TextIOBase): self.flush() if pos is None: pos = self.tell() - self.seek(pos) - return self.buffer.truncate() + return self.buffer.truncate(pos) def detach(self): if self.buffer is None: |