Skip to content

Commit

Permalink
Fetch module state by class where possible in winconsoleio.c
Browse files Browse the repository at this point in the history
  • Loading branch information
erlend-aasland committed May 10, 2023
1 parent 6fbda70 commit 50399ab
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Modules/_io/winconsoleio.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ _io__WindowsConsoleIO_readinto_impl(winconsoleio *self, PyTypeObject *cls,
Py_buffer *buffer)
/*[clinic end generated code: output=96717c74f6204b79 input=4b0627c3b1645f78]*/
{
_PyIO_State *state = IO_STATE();
_PyIO_State *state = get_io_state_by_cls(cls);
Py_ssize_t len = readinto(state, self, buffer->buf, buffer->len);
if (len < 0)
return NULL;
Expand Down Expand Up @@ -923,7 +923,7 @@ _io__WindowsConsoleIO_read_impl(winconsoleio *self, PyTypeObject *cls,
if (self->fd == -1)
return err_closed();
if (!self->readable) {
_PyIO_State *state = find_io_state_by_def(Py_TYPE(self));
_PyIO_State *state = get_io_state_by_cls(cls);
return err_mode(state, "reading");
}

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

_PyIO_State *state = find_io_state_by_def(Py_TYPE(self));
_PyIO_State *state = get_io_state_by_cls(cls);
bytes_size = readinto(state, self, PyBytes_AS_STRING(bytes),
PyBytes_GET_SIZE(bytes));
if (bytes_size < 0) {
Expand Down Expand Up @@ -981,7 +981,7 @@ _io__WindowsConsoleIO_write_impl(winconsoleio *self, PyTypeObject *cls,
if (self->fd == -1)
return err_closed();
if (!self->writable) {
_PyIO_State *state = find_io_state_by_def(Py_TYPE(self));
_PyIO_State *state = get_io_state_by_cls(cls);
return err_mode(state, "writing");
}

Expand Down

0 comments on commit 50399ab

Please sign in to comment.