mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #12062: Fix a flushing bug when doing a certain type of I/O sequence
on a file opened in read+write mode (namely: reading, seeking a bit forward, writing, then seeking before the previous write but still within buffered data, and writing again).
This commit is contained in:
commit
00dd182b8e
3 changed files with 33 additions and 1 deletions
|
@ -1838,7 +1838,7 @@ bufferedwriter_write(buffered *self, PyObject *args)
|
|||
avail = Py_SAFE_DOWNCAST(self->buffer_size - self->pos, Py_off_t, Py_ssize_t);
|
||||
if (buf.len <= avail) {
|
||||
memcpy(self->buffer + self->pos, buf.buf, buf.len);
|
||||
if (!VALID_WRITE_BUFFER(self)) {
|
||||
if (!VALID_WRITE_BUFFER(self) || self->write_pos > self->pos) {
|
||||
self->write_pos = self->pos;
|
||||
}
|
||||
ADJUST_POSITION(self, self->pos + buf.len);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue