Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

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 12 commits into from
May 9, 2023
Merged
Next Next commit
Refactor: replace query with parameter
Pass module state to bufferediobase_unsupported()
  • Loading branch information
erlend-aasland committed May 9, 2023
commit 14f923e938d89053653d3722770d81f8a5c814db
21 changes: 12 additions & 9 deletions 21 Modules/_io/bufferedio.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,9 @@ _io__BufferedIOBase_readinto1_impl(PyObject *self, Py_buffer *buffer)
}

static PyObject *
bufferediobase_unsupported(const char *message)
bufferediobase_unsupported(_PyIO_State *state, const char *message)
{
_PyIO_State *state = IO_STATE();
if (state != NULL)
PyErr_SetString(state->unsupported_operation, message);
PyErr_SetString(state->unsupported_operation, message);
return NULL;
}

Expand All @@ -127,7 +125,8 @@ static PyObject *
_io__BufferedIOBase_detach_impl(PyObject *self)
/*[clinic end generated code: output=754977c8d10ed88c input=822427fb58fe4169]*/
{
return bufferediobase_unsupported("detach");
_PyIO_State *state = IO_STATE();
return bufferediobase_unsupported(state, "detach");
}

PyDoc_STRVAR(bufferediobase_read_doc,
Expand All @@ -151,7 +150,8 @@ PyDoc_STRVAR(bufferediobase_read_doc,
static PyObject *
bufferediobase_read(PyObject *self, PyObject *args)
{
return bufferediobase_unsupported("read");
_PyIO_State *state = IO_STATE();
return bufferediobase_unsupported(state, "read");
}

PyDoc_STRVAR(bufferediobase_read1_doc,
Expand All @@ -164,7 +164,8 @@ PyDoc_STRVAR(bufferediobase_read1_doc,
static PyObject *
bufferediobase_read1(PyObject *self, PyObject *args)
{
return bufferediobase_unsupported("read1");
_PyIO_State *state = IO_STATE();
return bufferediobase_unsupported(state, "read1");
}

PyDoc_STRVAR(bufferediobase_write_doc,
Expand All @@ -179,7 +180,8 @@ PyDoc_STRVAR(bufferediobase_write_doc,
static PyObject *
bufferediobase_write(PyObject *self, PyObject *args)
{
return bufferediobase_unsupported("write");
_PyIO_State *state = IO_STATE();
return bufferediobase_unsupported(state, "write");
}


Expand Down Expand Up @@ -1298,7 +1300,8 @@ _io__Buffered_truncate_impl(buffered *self, PyObject *pos)
CHECK_INITIALIZED(self)
CHECK_CLOSED(self, "truncate of closed file")
if (!self->writable) {
return bufferediobase_unsupported("truncate");
_PyIO_State *state = IO_STATE();
return bufferediobase_unsupported(state, "truncate");
}
if (!ENTER_BUFFERED(self))
return NULL;
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.