summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/bufferedio.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index 98f8413..d8b6471 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -1757,6 +1757,19 @@ bufferedwriter_write(buffered *self, PyObject *args)
}
Py_CLEAR(res);
+ /* Adjust the raw stream position if it is away from the logical stream
+ position. This happens if the read buffer has been filled but not
+ modified (and therefore _bufferedwriter_flush_unlocked() didn't rewind
+ the raw stream by itself).
+ Fixes issue #6629.
+ */
+ n = RAW_OFFSET(self);
+ if (n != 0) {
+ if (_buffered_raw_seek(self, -n, 1) < 0)
+ goto error;
+ self->raw_pos -= n;
+ }
+
/* Then write buf itself. At this point the buffer has been emptied. */
remaining = buf.len;
written = 0;