mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
[3.12] gh-115059: Flush the underlying write buffer in io.BufferedRandom.read1() (GH-115163) (GH-115205)
(cherry picked from commit 846fd721d5)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
235c54fe9c
commit
0211f919b1
3 changed files with 63 additions and 0 deletions
|
|
@ -1015,6 +1015,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