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
Prev Previous commit
Next Next commit
Refactor: replace query with parameter
Pass module state to iobase_unsupported()
  • Loading branch information
erlend-aasland committed May 9, 2023
commit 482f13404ff6a7d1e1b3c4f158de641939bf0b7c
24 changes: 14 additions & 10 deletions 24 Modules/_io/iobase.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ PyDoc_STRVAR(iobase_doc,

/* Internal methods */
static PyObject *
iobase_unsupported(const char *message)
iobase_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 @@ -97,7 +95,8 @@ PyDoc_STRVAR(iobase_seek_doc,
static PyObject *
iobase_seek(PyObject *self, PyObject *args)
{
return iobase_unsupported("seek");
_PyIO_State *state = IO_STATE();
return iobase_unsupported(state, "seek");
}

/*[clinic input]
Expand All @@ -122,7 +121,8 @@ PyDoc_STRVAR(iobase_truncate_doc,
static PyObject *
iobase_truncate(PyObject *self, PyObject *args)
{
return iobase_unsupported("truncate");
_PyIO_State *state = IO_STATE();
return iobase_unsupported(state, "truncate");
}

static int
Expand Down Expand Up @@ -379,7 +379,8 @@ _PyIOBase_check_seekable(PyObject *self, PyObject *args)
return NULL;
if (res != Py_True) {
Py_CLEAR(res);
iobase_unsupported("File or stream is not seekable.");
_PyIO_State *state = IO_STATE();
iobase_unsupported(state, "File or stream is not seekable.");
return NULL;
}
if (args == Py_True) {
Expand Down Expand Up @@ -412,7 +413,8 @@ _PyIOBase_check_readable(PyObject *self, PyObject *args)
return NULL;
if (res != Py_True) {
Py_CLEAR(res);
iobase_unsupported("File or stream is not readable.");
_PyIO_State *state = IO_STATE();
iobase_unsupported(state, "File or stream is not readable.");
return NULL;
}
if (args == Py_True) {
Expand Down Expand Up @@ -445,7 +447,8 @@ _PyIOBase_check_writable(PyObject *self, PyObject *args)
return NULL;
if (res != Py_True) {
Py_CLEAR(res);
iobase_unsupported("File or stream is not writable.");
_PyIO_State *state = IO_STATE();
iobase_unsupported(state, "File or stream is not writable.");
return NULL;
}
if (args == Py_True) {
Expand Down Expand Up @@ -487,7 +490,8 @@ static PyObject *
_io__IOBase_fileno_impl(PyObject *self)
/*[clinic end generated code: output=7cc0973f0f5f3b73 input=4e37028947dc1cc8]*/
{
return iobase_unsupported("fileno");
_PyIO_State *state = IO_STATE();
return iobase_unsupported(state, "fileno");
}

/*[clinic input]
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.