mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
- 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.
This commit is contained in:
parent
e70c72c06b
commit
f3fa074703
12 changed files with 97 additions and 47 deletions
|
|
@ -414,7 +414,7 @@ PyDoc_STRVAR(truncate_doc,
|
|||
"truncate([size]) -> int. Truncate the file to at most size bytes.\n"
|
||||
"\n"
|
||||
"Size defaults to the current file position, as returned by tell().\n"
|
||||
"Returns the new size. Imply an absolute seek to the position size.");
|
||||
"The current file position is unchanged. Returns the new size.\n");
|
||||
|
||||
static PyObject *
|
||||
bytesio_truncate(bytesio *self, PyObject *args)
|
||||
|
|
@ -453,7 +453,6 @@ bytesio_truncate(bytesio *self, PyObject *args)
|
|||
if (resize_buffer(self, size) < 0)
|
||||
return NULL;
|
||||
}
|
||||
self->pos = size;
|
||||
|
||||
return PyLong_FromSsize_t(size);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue