summaryrefslogtreecommitdiffstats
path: root/Lib/_pyio.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-01-31 23:20:26 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-01-31 23:20:26 (GMT)
commit66f9fea782d330b28fe142ac4e58faff8a6f42d1 (patch)
tree664127f167fb8d906cf7f7de7d1e1557fea0e647 /Lib/_pyio.py
parent1665a8d9313660ffdcf3eda3eb1e1cc4eefcacee (diff)
downloadcpython-66f9fea782d330b28fe142ac4e58faff8a6f42d1.zip
cpython-66f9fea782d330b28fe142ac4e58faff8a6f42d1.tar.gz
cpython-66f9fea782d330b28fe142ac4e58faff8a6f42d1.tar.bz2
Merged revisions 77895-77896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r77895 | antoine.pitrou | 2010-01-31 23:47:27 +0100 (dim., 31 janv. 2010) | 12 lines 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. ........ ................ r77896 | antoine.pitrou | 2010-02-01 00:12:29 +0100 (lun., 01 févr. 2010) | 3 lines r77895 broke doctest. ................
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r--Lib/_pyio.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index 2458e40..a9ff985 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -851,7 +851,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
@@ -1210,8 +1210,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:
@@ -1712,8 +1711,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: