Skip to content

gh-132551: add missing critical sections on BytesIO methods #137073

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 1 commit into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions Modules/_io/bytesio.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,56 +270,60 @@ bytesio_get_closed(PyObject *op, void *Py_UNUSED(closure))
}

/*[clinic input]
@critical_section
_io.BytesIO.readable

Returns True if the IO object can be read.
[clinic start generated code]*/

static PyObject *
_io_BytesIO_readable_impl(bytesio *self)
/*[clinic end generated code: output=4e93822ad5b62263 input=96c5d0cccfb29f5c]*/
/*[clinic end generated code: output=4e93822ad5b62263 input=ab7816facef48bfd]*/
{
CHECK_CLOSED(self);
Py_RETURN_TRUE;
}

/*[clinic input]
@critical_section
_io.BytesIO.writable

Returns True if the IO object can be written.
[clinic start generated code]*/

static PyObject *
_io_BytesIO_writable_impl(bytesio *self)
/*[clinic end generated code: output=64ff6a254b1150b8 input=700eed808277560a]*/
/*[clinic end generated code: output=64ff6a254b1150b8 input=4f35d49d26dab024]*/
{
CHECK_CLOSED(self);
Py_RETURN_TRUE;
}

/*[clinic input]
@critical_section
_io.BytesIO.seekable

Returns True if the IO object can be seeked.
[clinic start generated code]*/

static PyObject *
_io_BytesIO_seekable_impl(bytesio *self)
/*[clinic end generated code: output=6b417f46dcc09b56 input=9421f65627a344dd]*/
/*[clinic end generated code: output=6b417f46dcc09b56 input=9cc78d15aa1deaa3]*/
{
CHECK_CLOSED(self);
Py_RETURN_TRUE;
}

/*[clinic input]
@critical_section
_io.BytesIO.flush

Does nothing.
[clinic start generated code]*/

static PyObject *
_io_BytesIO_flush_impl(bytesio *self)
/*[clinic end generated code: output=187e3d781ca134a0 input=561ea490be4581a7]*/
/*[clinic end generated code: output=187e3d781ca134a0 input=c60842743910b381]*/
{
CHECK_CLOSED(self);
Py_RETURN_NONE;
Expand Down Expand Up @@ -385,6 +389,7 @@ _io_BytesIO_getvalue_impl(bytesio *self)
}

/*[clinic input]
@critical_section
_io.BytesIO.isatty

Always returns False.
Expand All @@ -394,7 +399,7 @@ BytesIO objects are not connected to a TTY-like device.

static PyObject *
_io_BytesIO_isatty_impl(bytesio *self)
/*[clinic end generated code: output=df67712e669f6c8f input=6f97f0985d13f827]*/
/*[clinic end generated code: output=df67712e669f6c8f input=50487b74dc5ae8a9]*/
{
CHECK_CLOSED(self);
Py_RETURN_FALSE;
Expand Down
42 changes: 36 additions & 6 deletions Modules/_io/clinic/bytesio.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading