8000 gh-101819: Refactor _io futher in preparation for module isolation by erlend-aasland · Pull Request #104369 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-101819: Refactor _io futher in preparation for module isolation #104369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 11, 2023
Merged
Prev Previous commit
Next Next commit
Refactor: replace query with parameter
Pass module state to readinto() in winconsoleio.c
  • Loading branch information
erlend-aasland committed May 10, 2023
commit 6fbda701ba735386d2a629d28b6e084632c9de72
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