Skip to content

Commit

Permalink
Refactor: replace query with parameter
Browse files Browse the repository at this point in the history
Pass module state to readinto() in winconsoleio.c
  • Loading branch information
erlend-aasland committed May 10, 2023
1 parent c07026f commit 6fbda70
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Modules/_io/winconsoleio.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,14 +637,13 @@ read_console_w(HANDLE handle, DWORD maxlen, DWORD *readlen) {


static Py_ssize_t
readinto(winconsoleio *self, char *buf, Py_ssize_t len)
readinto(_PyIO_State *state, winconsoleio *self, char *buf, Py_ssize_t len)
{
if (self->fd == -1) {
err_closed();
return -1;
}
if (!self->readable) {
_PyIO_State *state = find_io_state_by_def(Py_TYPE(self));
err_mode(state, "reading");
return -1;
}
Expand Down Expand Up @@ -747,7 +746,8 @@ _io__WindowsConsoleIO_readinto_impl(winconsoleio *self, PyTypeObject *cls,
Py_buffer *buffer)
/*[clinic end generated code: output=96717c74f6204b79 input=4b0627c3b1645f78]*/
{
Py_ssize_t len = readinto(self, buffer->buf, buffer->len);
_PyIO_State *state = IO_STATE();
Py_ssize_t len = readinto(state, self, buffer->buf, buffer->len);
if (len < 0)
return NULL;

Expand Down Expand Up @@ -938,7 +938,9 @@ _io__WindowsConsoleIO_read_impl(winconsoleio *self, PyTypeObject *cls,
if (bytes == NULL)
return NULL;

bytes_size = readinto(self, PyBytes_AS_STRING(bytes), PyBytes_GET_SIZE(bytes));
_PyIO_State *state = find_io_state_by_def(Py_TYPE(self));
bytes_size = readinto(state, self, PyBytes_AS_STRING(bytes),
PyBytes_GET_SIZE(bytes));
if (bytes_size < 0) {
Py_CLEAR(bytes);
return NULL;
Expand Down

0 comments on commit 6fbda70

Please sign in to comment.