Skip to content
Open
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
53 changes: 27 additions & 26 deletions Objects/cellobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@
#include "pycore_modsupport.h" // _PyArg_NoKeywords()
#include "pycore_object.h"

#include "clinic/cellobject.c.h"

#define _PyCell_CAST(op) _Py_CAST(PyCellObject*, (op))

/*[clinic input]
class cell "PyCellObject *" "&PyCell_Type"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=3d6baba8cf810af0]*/

PyObject *
PyCell_New(PyObject *obj)
{
Expand All @@ -21,35 +28,28 @@ PyCell_New(PyObject *obj)
return (PyObject *)op;
}

PyDoc_STRVAR(cell_new_doc,
"cell([contents])\n"
"--\n"
"\n"
"Create a new cell object.\n"
"\n"
" contents\n"
" the contents of the cell. If not specified, the cell will be empty,\n"
" and further attempts to access its cell_contents attribute will\n"
" raise a ValueError.");
/*[clinic input]
@vectorcall
@classmethod
@text_signature "([contents])"
cell.__new__ as cell_new

contents: object(c_default="NULL") = None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this signature isn't technically the same as the old "defaults to None" and "has two overloads, 0 args and 1 arg" have some behavior differences... not certain how critical that is here...

To land this quickly I'd suggest using a @text_signature to keep the old signature. Adding optional group support to AC VC will likely be a bit (Although is looking like something I should prioritize)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use @text_signature and revert previous test fix.

/

static PyObject *
cell_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
PyObject *obj = NULL;
Create a new cell object.

if (!_PyArg_NoKeywords("cell", kwargs)) {
goto exit;
}
/* min = 0: we allow the cell to be empty */
if (!PyArg_UnpackTuple(args, "cell", 0, 1, &obj)) {
goto exit;
}
return_value = PyCell_New(obj);
contents
the contents of the cell. If not specified, the cell will be empty,
and further attempts to access its cell_contents attribute will
raise a ValueError.
[clinic start generated code]*/

exit:
return return_value;
static PyObject *
cell_new_impl(PyTypeObject *type, PyObject *contents)
/*[clinic end generated code: output=0b7db264f0621bb4 input=2772e49193d8e5d9]*/
{
return PyCell_New(contents);
}

PyObject *
Expand Down Expand Up @@ -190,7 +190,7 @@ PyTypeObject PyCell_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
cell_new_doc, /* tp_doc */
cell_new__doc__, /* tp_doc */
cell_traverse, /* tp_traverse */
cell_clear, /* tp_clear */
cell_richcompare, /* tp_richcompare */
Expand All @@ -209,4 +209,5 @@ PyTypeObject PyCell_Type = {
0, /* tp_alloc */
cell_new, /* tp_new */
0, /* tp_free */
.tp_vectorcall = cell_vectorcall,
};
74 changes: 74 additions & 0 deletions Objects/clinic/cellobject.c.h

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

Loading