mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
gh-115059: Flush the underlying write buffer in io.BufferedRandom.read1() (GH-115163)
This commit is contained in:
parent
c968dc7ff3
commit
846fd721d5
3 changed files with 63 additions and 0 deletions
|
|
@ -1050,6 +1050,16 @@ _io__Buffered_read1_impl(buffered *self, Py_ssize_t n)
|
|||
Py_DECREF(res);
|
||||
return NULL;
|
||||
}
|
||||
/* Flush the write buffer if necessary */
|
||||
if (self->writable) {
|
||||
PyObject *r = buffered_flush_and_rewind_unlocked(self);
|
||||
if (r == NULL) {
|
||||
LEAVE_BUFFERED(self)
|
||||
Py_DECREF(res);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(r);
|
||||
}
|
||||
_bufferedreader_reset_buf(self);
|
||||
r = _bufferedreader_raw_read(self, PyBytes_AS_STRING(res), n);
|
||||
LEAVE_BUFFERED(self)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue