mirror of https://github.com/python/cpython
gh-111178: Fix function signatures in cellobject.c (#125182)
This commit is contained in:
parent
a5716a3091
commit
440632adb2
|
@ -5,6 +5,8 @@
|
|||
#include "pycore_modsupport.h" // _PyArg_NoKeywords()
|
||||
#include "pycore_object.h"
|
||||
|
||||
#define _PyCell_CAST(op) _Py_CAST(PyCellObject*, (op))
|
||||
|
||||
PyObject *
|
||||
PyCell_New(PyObject *obj)
|
||||
{
|
||||
|
@ -72,8 +74,9 @@ PyCell_Set(PyObject *op, PyObject *value)
|
|||
}
|
||||
|
||||
static void
|
||||
cell_dealloc(PyCellObject *op)
|
||||
cell_dealloc(PyObject *self)
|
||||
{
|
||||
PyCellObject *op = _PyCell_CAST(self);
|
||||
_PyObject_GC_UNTRACK(op);
|
||||
Py_XDECREF(op->ob_ref);
|
||||
PyObject_GC_Del(op);
|
||||
|
@ -100,10 +103,12 @@ cell_richcompare(PyObject *a, PyObject *b, int op)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
cell_repr(PyCellObject *op)
|
||||
cell_repr(PyObject *self)
|
||||
{
|
||||
if (op->ob_ref == NULL)
|
||||
PyCellObject *op = _PyCell_CAST(self);
|
||||
if (op->ob_ref == NULL) {
|
||||
return PyUnicode_FromFormat("<cell at %p: empty>", op);
|
||||
}
|
||||
|
||||
return PyUnicode_FromFormat("<cell at %p: %.80s object at %p>",
|
||||
op, Py_TYPE(op->ob_ref)->tp_name,
|
||||
|
@ -111,24 +116,26 @@ cell_repr(PyCellObject *op)
|
|||
}
|
||||
|
||||
static int
|
||||
cell_traverse(PyCellObject *op, visitproc visit, void *arg)
|
||||
cell_traverse(PyObject *self, visitproc visit, void *arg)
|
||||
{
|
||||
PyCellObject *op = _PyCell_CAST(self);
|
||||
Py_VISIT(op->ob_ref);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
cell_clear(PyCellObject *op)
|
||||
cell_clear(PyObject *self)
|
||||
{
|
||||
PyCellObject *op = _PyCell_CAST(self);
|
||||
Py_CLEAR(op->ob_ref);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
cell_get_contents(PyCellObject *op, void *closure)
|
||||
cell_get_contents(PyObject *self, void *closure)
|
||||
{
|
||||
if (op->ob_ref == NULL)
|
||||
{
|
||||
PyCellObject *op = _PyCell_CAST(self);
|
||||
if (op->ob_ref == NULL) {
|
||||
PyErr_SetString(PyExc_ValueError, "Cell is empty");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -136,15 +143,15 @@ cell_get_contents(PyCellObject *op, void *closure)
|
|||
}
|
||||
|
||||
static int
|
||||
cell_set_contents(PyCellObject *op, PyObject *obj, void *Py_UNUSED(ignored))
|
||||
cell_set_contents(PyObject *self, PyObject *obj, void *Py_UNUSED(ignored))
|
||||
{
|
||||
PyCellObject *op = _PyCell_CAST(self);
|
||||
Py_XSETREF(op->ob_ref, Py_XNewRef(obj));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyGetSetDef cell_getsetlist[] = {
|
||||
{"cell_contents", (getter)cell_get_contents,
|
||||
(setter)cell_set_contents, NULL},
|
||||
{"cell_contents", cell_get_contents, cell_set_contents, NULL},
|
||||
{NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
@ -153,12 +160,12 @@ PyTypeObject PyCell_Type = {
|
|||
"cell",
|
||||
sizeof(PyCellObject),
|
||||
0,
|
||||
(destructor)cell_dealloc, /* tp_dealloc */
|
||||
cell_dealloc, /* tp_dealloc */
|
||||
0, /* tp_vectorcall_offset */
|
||||
0, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_as_async */
|
||||
(reprfunc)cell_repr, /* tp_repr */
|
||||
cell_repr, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
|
@ -170,8 +177,8 @@ PyTypeObject PyCell_Type = {
|
|||
0, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
||||
cell_new_doc, /* tp_doc */
|
||||
(traverseproc)cell_traverse, /* tp_traverse */
|
||||
(inquiry)cell_clear, /* tp_clear */
|
||||
cell_traverse, /* tp_traverse */
|
||||
cell_clear, /* tp_clear */
|
||||
cell_richcompare, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
|
@ -186,6 +193,6 @@ PyTypeObject PyCell_Type = {
|
|||
0, /* tp_dictoffset */
|
||||
0, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
(newfunc)cell_new, /* tp_new */
|
||||
cell_new, /* tp_new */
|
||||
0, /* tp_free */
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue