Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address cmaloney's review
Move PyBytesWriter_Create() call
  • Loading branch information
vstinner committed Sep 15, 2025
commit dd3f975156c9c5b0ca3c912dac2fef4d3d1ad771
13 changes: 7 additions & 6 deletions Modules/_io/bufferedio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1048,25 +1048,26 @@ _io__Buffered_read1_impl(buffered *self, Py_ssize_t n)
return res;
}

PyBytesWriter *writer = PyBytesWriter_Create(n);
if (writer == NULL) {
return NULL;
}
if (!ENTER_BUFFERED(self)) {
PyBytesWriter_Discard(writer);
return NULL;
}

/* Flush the write buffer if necessary */
if (self->writable) {
PyObject *res = buffered_flush_and_rewind_unlocked(self);
if (res == NULL) {
LEAVE_BUFFERED(self)
PyBytesWriter_Discard(writer);
return NULL;
}
Py_DECREF(res);
}
_bufferedreader_reset_buf(self);

PyBytesWriter *writer = PyBytesWriter_Create(n);
if (writer == NULL) {
return NULL;
}

Py_ssize_t r = _bufferedreader_raw_read(self,
PyBytesWriter_GetData(writer), n);
LEAVE_BUFFERED(self)
Expand Down
Loading