summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-05-12 22:31:52 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-05-12 22:31:52 (GMT)
commitee46a7bf9cf60a318d868c5a4c55ee5020c416d4 (patch)
treeb9cf21311638e6cb05073e5678be288b68e09617 /Modules
parent073070629bfd8162bf969da961e929366d1d8f7c (diff)
downloadcpython-ee46a7bf9cf60a318d868c5a4c55ee5020c416d4.zip
cpython-ee46a7bf9cf60a318d868c5a4c55ee5020c416d4.tar.gz
cpython-ee46a7bf9cf60a318d868c5a4c55ee5020c416d4.tar.bz2
Issue #12062: In the `io` module, 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).
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_io/bufferedio.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index 5816a93..144aea2 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -1810,7 +1810,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);