Skip to content
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

gh-112205: Update stringio module to use AC for the thread-safe #112549

Merged
merged 1 commit into from
Nov 30, 2023
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
56 changes: 55 additions & 1 deletion Modules/_io/clinic/stringio.c.h

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

58 changes: 24 additions & 34 deletions Modules/_io/stringio.c
Original file line number Diff line number Diff line change
Expand Up @@ -970,44 +970,44 @@ _io_StringIO___setstate___impl(stringio *self, PyObject *state)
Py_RETURN_NONE;
}

/*[clinic input]
@critical_section
@getter
_io.StringIO.closed
[clinic start generated code]*/

static PyObject *
stringio_closed_impl(stringio *self, void *context)
_io_StringIO_closed_get_impl(stringio *self)
/*[clinic end generated code: output=531ddca7954331d6 input=178d2ef24395fd49]*/
{
CHECK_INITIALIZED(self);
return PyBool_FromLong(self->closed);
}

static PyObject *
stringio_closed(stringio *self, void *context)
{
PyObject *result;
Py_BEGIN_CRITICAL_SECTION(self);
result = stringio_closed_impl(self, context);
Py_END_CRITICAL_SECTION();
return result;
}
/*[clinic input]
@critical_section
@getter
_io.StringIO.line_buffering
[clinic start generated code]*/

static PyObject *
stringio_line_buffering_impl(stringio *self, void *context)
_io_StringIO_line_buffering_get_impl(stringio *self)
/*[clinic end generated code: output=360710e0112966ae input=6a7634e7f890745e]*/
{
CHECK_INITIALIZED(self);
CHECK_CLOSED(self);
Py_RETURN_FALSE;
}

static PyObject *
stringio_line_buffering(stringio *self, void *context)
{
PyObject *result;
Py_BEGIN_CRITICAL_SECTION(self);
result = stringio_line_buffering_impl(self, context);
Py_END_CRITICAL_SECTION();
return result;
}
/*[clinic input]
@critical_section
@getter
_io.StringIO.newlines
[clinic start generated code]*/

static PyObject *
stringio_newlines_impl(stringio *self, void *context)
_io_StringIO_newlines_get_impl(stringio *self)
/*[clinic end generated code: output=35d7c0b66d7e0160 input=092a14586718244b]*/
{
CHECK_INITIALIZED(self);
CHECK_CLOSED(self);
Expand All @@ -1017,16 +1017,6 @@ stringio_newlines_impl(stringio *self, void *context)
return PyObject_GetAttr(self->decoder, &_Py_ID(newlines));
}

static PyObject *
stringio_newlines(stringio *self, void *context)
{
PyObject *result;
Py_BEGIN_CRITICAL_SECTION(self);
result = stringio_newlines_impl(self, context);
Py_END_CRITICAL_SECTION();
return result;
}

static struct PyMethodDef stringio_methods[] = {
_IO_STRINGIO_CLOSE_METHODDEF
_IO_STRINGIO_GETVALUE_METHODDEF
Expand All @@ -1047,15 +1037,15 @@ static struct PyMethodDef stringio_methods[] = {
};

static PyGetSetDef stringio_getset[] = {
{"closed", (getter)stringio_closed, NULL, NULL},
{"newlines", (getter)stringio_newlines, NULL, NULL},
_IO_STRINGIO_CLOSED_GETTERDEF
_IO_STRINGIO_NEWLINES_GETTERDEF
/* (following comments straight off of the original Python wrapper:)
XXX Cruft to support the TextIOWrapper API. This would only
be meaningful if StringIO supported the buffer attribute.
Hopefully, a better solution, than adding these pseudo-attributes,
will be found.
*/
{"line_buffering", (getter)stringio_line_buffering, NULL, NULL},
_IO_STRINGIO_LINE_BUFFERING_GETTERDEF
{NULL}
};

Expand Down
Loading