Skip to content

gh-111178: Change Argument Clinic signature for METH_O #130682

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 10 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from 5 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
39 changes: 28 additions & 11 deletions Lib/test/clinic.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -4910,16 +4910,21 @@ Test_cls_no_params_impl(TestObj *self, PyTypeObject *cls);
static PyObject *
Test_cls_no_params(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;

if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) {
PyErr_SetString(PyExc_TypeError, "cls_no_params() takes no arguments");
return NULL;
goto exit;
}
return Test_cls_no_params_impl((TestObj *)self, cls);
return_value = Test_cls_no_params_impl((TestObj *)self, cls);

exit:
return return_value;
}

static PyObject *
Test_cls_no_params_impl(TestObj *self, PyTypeObject *cls)
/*[clinic end generated code: output=8845de054449f40a input=e7e2e4e344e96a11]*/
/*[clinic end generated code: output=70c0b4bfb2ea3bab input=e7e2e4e344e96a11]*/


/*[clinic input]
Expand All @@ -4940,7 +4945,7 @@ static int
Test_metho_not_default_return_converter_impl(TestObj *self, PyObject *a);

static PyObject *
Test_metho_not_default_return_converter(TestObj *self, PyObject *a)
Test_metho_not_default_return_converter(PyObject *self, PyObject *a)
{
PyObject *return_value = NULL;
int _return_value;
Expand All @@ -4957,7 +4962,7 @@ Test_metho_not_default_return_converter(TestObj *self, PyObject *a)

static int
Test_metho_not_default_return_converter_impl(TestObj *self, PyObject *a)
/*[clinic end generated code: output=b2cce75a7af2e6ce input=428657129b521177]*/
/*[clinic end generated code: output=8b03f5213c312138 input=428657129b521177]*/


/*[clinic input]
Expand Down Expand Up @@ -5291,12 +5296,16 @@ Test_meth_coexist_impl(TestObj *self);
static PyObject *
Test_meth_coexist(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return Test_meth_coexist_impl((TestObj *)self);
PyObject *return_value = NULL;

return_value = Test_meth_coexist_impl((TestObj *)self);

return return_value;
}

static PyObject *
Test_meth_coexist_impl(TestObj *self)
/*[clinic end generated code: output=7edf4e95b29f06fa input=2a1d75b5e6fec6dd]*/
/*[clinic end generated code: output=09e0fbba4ffb08df input=2a1d75b5e6fec6dd]*/

/*[clinic input]
@getter
Expand All @@ -5319,12 +5328,16 @@ Test_property_get_impl(TestObj *self);
static PyObject *
Test_property_get(PyObject *self, void *Py_UNUSED(context))
{
return Test_property_get_impl((TestObj *)self);
PyObject *return_value = NULL;

return_value = Test_property_get_impl((TestObj *)self);

return return_value;
}

static PyObject *
Test_property_get_impl(TestObj *self)
/*[clinic end generated code: output=b38d68abd3466a6e input=2d92b3449fbc7d2b]*/
/*[clinic end generated code: output=117f470c76def2b0 input=2d92b3449fbc7d2b]*/

/*[clinic input]
@setter
Expand Down Expand Up @@ -5420,12 +5433,16 @@ Test_setter_first_with_docstr_get_impl(TestObj *self);
static PyObject *
Test_setter_first_with_docstr_get(PyObject *self, void *Py_UNUSED(context))
{
return Test_setter_first_with_docstr_get_impl((TestObj *)self);
PyObject *return_value = NULL;

return_value = Test_setter_first_with_docstr_get_impl((TestObj *)self);

return return_value;
}

static PyObject *
Test_setter_first_with_docstr_get_impl(TestObj *self)
/*[clinic end generated code: output=fe6e3aa844a24920 input=10af4e43b3cb34dc]*/
/*[clinic end generated code: output=ee74b65390f451f6 input=10af4e43b3cb34dc]*/

/*[clinic input]
output push
Expand Down
8 changes: 4 additions & 4 deletions Modules/_asynciomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2749,8 +2749,8 @@ _asyncio.Task.set_result
[clinic start generated code]*/

static PyObject *
_asyncio_Task_set_result(TaskObj *self, PyObject *result)
/*[clinic end generated code: output=1dcae308bfcba318 input=9d1a00c07be41bab]*/
_asyncio_Task_set_result_impl(TaskObj *self, PyObject *result)
/*[clinic end generated code: output=e9d8e3cdaf18e258 input=9d1a00c07be41bab]*/
{
PyErr_SetString(PyExc_RuntimeError,
"Task does not support set_result operation");
Expand All @@ -2765,8 +2765,8 @@ _asyncio.Task.set_exception
[clinic start generated code]*/

static PyObject *
_asyncio_Task_set_exception(TaskObj *self, PyObject *exception)
/*[clinic end generated code: output=bc377fc28067303d input=9a8f65c83dcf893a]*/
_asyncio_Task_set_exception_impl(TaskObj *self, PyObject *exception)
/*[clinic end generated code: output=96a91790c192cc7d input=9a8f65c83dcf893a]*/
{
PyErr_SetString(PyExc_RuntimeError,
"Task does not support set_exception operation");
Expand Down
4 changes: 2 additions & 2 deletions Modules/_collectionsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ deque_extend_impl(dequeobject *deque, PyObject *iterable)
PyObject *s = PySequence_List(iterable);
if (s == NULL)
return NULL;
result = deque_extend(deque, s);
result = deque_extend_impl(deque, s);
Py_DECREF(s);
return result;
}
Expand Down Expand Up @@ -578,7 +578,7 @@ deque_inplace_concat(PyObject *self, PyObject *other)
PyObject *result;

// deque_extend is thread-safe
result = deque_extend(deque, other);
result = deque_extend_impl(deque, other);
if (result == NULL)
return result;
Py_INCREF(deque);
Expand Down
4 changes: 2 additions & 2 deletions Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2309,8 +2309,8 @@ This information can be later retrieved using the getwin() function.
[clinic start generated code]*/

static PyObject *
_curses_window_putwin(PyCursesWindowObject *self, PyObject *file)
/*[clinic end generated code: output=3a25e2a5e7a040ac input=0608648e09c8ea0a]*/
_curses_window_putwin_impl(PyCursesWindowObject *self, PyObject *file)
/*[clinic end generated code: output=fdae68ac59b0281b input=0608648e09c8ea0a]*/
{
/* We have to simulate this by writing to a temporary FILE*,
then reading back, then writing to the argument file. */
Expand Down
22 changes: 12 additions & 10 deletions Modules/_elementtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2951,8 +2951,8 @@ _elementtree.TreeBuilder.data
[clinic start generated code]*/

static PyObject *
_elementtree_TreeBuilder_data(TreeBuilderObject *self, PyObject *data)
/*[clinic end generated code: output=69144c7100795bb2 input=a0540c532b284d29]*/
_elementtree_TreeBuilder_data_impl(TreeBuilderObject *self, PyObject *data)
/*[clinic end generated code: output=dfa02b68f732b8c0 input=a0540c532b284d29]*/
{
return treebuilder_handle_data(self, data);
}
Expand All @@ -2966,8 +2966,8 @@ _elementtree.TreeBuilder.end
[clinic start generated code]*/

static PyObject *
_elementtree_TreeBuilder_end(TreeBuilderObject *self, PyObject *tag)
/*[clinic end generated code: output=9a98727cc691cd9d input=22dc3674236f5745]*/
_elementtree_TreeBuilder_end_impl(TreeBuilderObject *self, PyObject *tag)
/*[clinic end generated code: output=84cb6ca9008ec740 input=22dc3674236f5745]*/
{
return treebuilder_handle_end(self, tag);
}
Expand All @@ -2981,8 +2981,9 @@ _elementtree.TreeBuilder.comment
[clinic start generated code]*/

static PyObject *
_elementtree_TreeBuilder_comment(TreeBuilderObject *self, PyObject *text)
/*[clinic end generated code: output=22835be41deeaa27 input=47e7ebc48ed01dfa]*/
_elementtree_TreeBuilder_comment_impl(TreeBuilderObject *self,
PyObject *text)
/*[clinic end generated code: output=a555ef39027c3823 input=47e7ebc48ed01dfa]*/
{
return treebuilder_handle_comment(self, text);
}
Expand Down Expand Up @@ -3949,8 +3950,8 @@ _elementtree.XMLParser.feed
[clinic start generated code]*/

static PyObject *
_elementtree_XMLParser_feed(XMLParserObject *self, PyObject *data)
/*[clinic end generated code: output=e42b6a78eec7446d input=fe231b6b8de3ce1f]*/
_elementtree_XMLParser_feed_impl(XMLParserObject *self, PyObject *data)
/*[clinic end generated code: output=503e6fbf1adf17ab input=fe231b6b8de3ce1f]*/
{
/* feed data to parser */

Expand Down Expand Up @@ -3997,8 +3998,9 @@ _elementtree.XMLParser._parse_whole
[clinic start generated code]*/

static PyObject *
_elementtree_XMLParser__parse_whole(XMLParserObject *self, PyObject *file)
/*[clinic end generated code: output=f797197bb818dda3 input=19ecc893b6f3e752]*/
_elementtree_XMLParser__parse_whole_impl(XMLParserObject *self,
PyObject *file)
/*[clinic end generated code: output=60718a4e63d237d2 input=19ecc893b6f3e752]*/
{
/* (internal) parse the whole input, until end of stream */
PyObject* reader;
Expand Down
4 changes: 2 additions & 2 deletions Modules/_hashopenssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,8 @@ Update this hash object's state with the provided string.
[clinic start generated code]*/

static PyObject *
EVP_update(EVPobject *self, PyObject *obj)
/*[clinic end generated code: output=ec1d55ed2432e966 input=9b30ec848f015501]*/
EVP_update_impl(EVPobject *self, PyObject *obj)
/*[clinic end generated code: output=d56f91c68348f95f input=9b30ec848f015501]*/
{
int result;
Py_buffer view;
Expand Down
6 changes: 3 additions & 3 deletions Modules/_io/bufferedio.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@ _io._Buffered._dealloc_warn
[clinic start generated code]*/

static PyObject *
_io__Buffered__dealloc_warn(buffered *self, PyObject *source)
/*[clinic end generated code: output=690dcc3df8967162 input=8f845f2a4786391c]*/
_io__Buffered__dealloc_warn_impl(buffered *self, PyObject *source)
/*[clinic end generated code: output=d8db21c6dec0e614 input=8f845f2a4786391c]*/
{
if (self->ok && self->raw) {
PyObject *r;
Expand Down Expand Up @@ -560,7 +560,7 @@ _io__Buffered_close_impl(buffered *self)
}

if (self->finalizing) {
PyObject *r = _io__Buffered__dealloc_warn(self, (PyObject *) self);
PyObject *r = _io__Buffered__dealloc_warn_impl(self, (PyObject *) self);
if (r)
Py_DECREF(r);
else
Expand Down
12 changes: 6 additions & 6 deletions Modules/_io/bytesio.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,8 @@ Return the number of bytes written.
[clinic start generated code]*/

static PyObject *
_io_BytesIO_write(bytesio *self, PyObject *b)
/*[clinic end generated code: output=53316d99800a0b95 input=f5ec7c8c64ed720a]*/
_io_BytesIO_write_impl(bytesio *self, PyObject *b)
/*[clinic end generated code: output=d3e46bcec8d9e21c input=f5ec7c8c64ed720a]*/
{
Py_ssize_t n = write_bytes(self, b);
return n >= 0 ? PyLong_FromSsize_t(n) : NULL;
Expand All @@ -730,8 +730,8 @@ each element.
[clinic start generated code]*/

static PyObject *
_io_BytesIO_writelines(bytesio *self, PyObject *lines)
/*[clinic end generated code: output=7f33aa3271c91752 input=e972539176fc8fc1]*/
_io_BytesIO_writelines_impl(bytesio *self, PyObject *lines)
/*[clinic end generated code: output=03a43a75773bc397 input=e972539176fc8fc1]*/
{
PyObject *it, *item;

Expand Down Expand Up @@ -842,7 +842,7 @@ bytesio_setstate(PyObject *op, PyObject *state)

/* Set the value of the internal buffer. If state[0] does not support the
buffer protocol, bytesio_write will raise the appropriate TypeError. */
result = _io_BytesIO_write(self, PyTuple_GET_ITEM(state, 0));
result = _io_BytesIO_write_impl(self, PyTuple_GET_ITEM(state, 0));
if (result == NULL)
return NULL;
Py_DECREF(result);
Expand Down Expand Up @@ -958,7 +958,7 @@ _io_BytesIO___init___impl(bytesio *self, PyObject *initvalue)
}
else {
PyObject *res;
res = _io_BytesIO_write(self, initvalue);
res = _io_BytesIO_write_impl(self, initvalue);
if (res == NULL)
return -1;
Py_DECREF(res);
Expand Down
15 changes: 14 additions & 1 deletion Modules/_io/clinic/bufferedio.c.h

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

Loading
Loading