mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
gh-111178: Fix function signatures in namespaceobject.c (#130590)
This commit is contained in:
parent
1b635d86cd
commit
d5d4cbbd8f
1 changed files with 16 additions and 10 deletions
|
@ -12,6 +12,8 @@ typedef struct {
|
||||||
PyObject *ns_dict;
|
PyObject *ns_dict;
|
||||||
} _PyNamespaceObject;
|
} _PyNamespaceObject;
|
||||||
|
|
||||||
|
#define _PyNamespace_CAST(op) _Py_CAST(_PyNamespaceObject*, (op))
|
||||||
|
|
||||||
|
|
||||||
static PyMemberDef namespace_members[] = {
|
static PyMemberDef namespace_members[] = {
|
||||||
{"__dict__", _Py_T_OBJECT, offsetof(_PyNamespaceObject, ns_dict), Py_READONLY},
|
{"__dict__", _Py_T_OBJECT, offsetof(_PyNamespaceObject, ns_dict), Py_READONLY},
|
||||||
|
@ -41,8 +43,9 @@ namespace_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
namespace_init(_PyNamespaceObject *ns, PyObject *args, PyObject *kwds)
|
namespace_init(PyObject *op, PyObject *args, PyObject *kwds)
|
||||||
{
|
{
|
||||||
|
_PyNamespaceObject *ns = _PyNamespace_CAST(op);
|
||||||
PyObject *arg = NULL;
|
PyObject *arg = NULL;
|
||||||
if (!PyArg_UnpackTuple(args, _PyType_Name(Py_TYPE(ns)), 0, 1, &arg)) {
|
if (!PyArg_UnpackTuple(args, _PyType_Name(Py_TYPE(ns)), 0, 1, &arg)) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -76,8 +79,9 @@ namespace_init(_PyNamespaceObject *ns, PyObject *args, PyObject *kwds)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
namespace_dealloc(_PyNamespaceObject *ns)
|
namespace_dealloc(PyObject *op)
|
||||||
{
|
{
|
||||||
|
_PyNamespaceObject *ns = _PyNamespace_CAST(op);
|
||||||
PyObject_GC_UnTrack(ns);
|
PyObject_GC_UnTrack(ns);
|
||||||
Py_CLEAR(ns->ns_dict);
|
Py_CLEAR(ns->ns_dict);
|
||||||
Py_TYPE(ns)->tp_free((PyObject *)ns);
|
Py_TYPE(ns)->tp_free((PyObject *)ns);
|
||||||
|
@ -169,16 +173,18 @@ error:
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
namespace_traverse(_PyNamespaceObject *ns, visitproc visit, void *arg)
|
namespace_traverse(PyObject *op, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
|
_PyNamespaceObject *ns = _PyNamespace_CAST(op);
|
||||||
Py_VISIT(ns->ns_dict);
|
Py_VISIT(ns->ns_dict);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
namespace_clear(_PyNamespaceObject *ns)
|
namespace_clear(PyObject *op)
|
||||||
{
|
{
|
||||||
|
_PyNamespaceObject *ns = _PyNamespace_CAST(op);
|
||||||
Py_CLEAR(ns->ns_dict);
|
Py_CLEAR(ns->ns_dict);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -258,12 +264,12 @@ PyTypeObject _PyNamespace_Type = {
|
||||||
"types.SimpleNamespace", /* tp_name */
|
"types.SimpleNamespace", /* tp_name */
|
||||||
sizeof(_PyNamespaceObject), /* tp_basicsize */
|
sizeof(_PyNamespaceObject), /* tp_basicsize */
|
||||||
0, /* tp_itemsize */
|
0, /* tp_itemsize */
|
||||||
(destructor)namespace_dealloc, /* tp_dealloc */
|
namespace_dealloc, /* tp_dealloc */
|
||||||
0, /* tp_vectorcall_offset */
|
0, /* tp_vectorcall_offset */
|
||||||
0, /* tp_getattr */
|
0, /* tp_getattr */
|
||||||
0, /* tp_setattr */
|
0, /* tp_setattr */
|
||||||
0, /* tp_as_async */
|
0, /* tp_as_async */
|
||||||
(reprfunc)namespace_repr, /* tp_repr */
|
namespace_repr, /* tp_repr */
|
||||||
0, /* tp_as_number */
|
0, /* tp_as_number */
|
||||||
0, /* tp_as_sequence */
|
0, /* tp_as_sequence */
|
||||||
0, /* tp_as_mapping */
|
0, /* tp_as_mapping */
|
||||||
|
@ -276,8 +282,8 @@ PyTypeObject _PyNamespace_Type = {
|
||||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
|
||||||
Py_TPFLAGS_BASETYPE, /* tp_flags */
|
Py_TPFLAGS_BASETYPE, /* tp_flags */
|
||||||
namespace_doc, /* tp_doc */
|
namespace_doc, /* tp_doc */
|
||||||
(traverseproc)namespace_traverse, /* tp_traverse */
|
namespace_traverse, /* tp_traverse */
|
||||||
(inquiry)namespace_clear, /* tp_clear */
|
namespace_clear, /* tp_clear */
|
||||||
namespace_richcompare, /* tp_richcompare */
|
namespace_richcompare, /* tp_richcompare */
|
||||||
0, /* tp_weaklistoffset */
|
0, /* tp_weaklistoffset */
|
||||||
0, /* tp_iter */
|
0, /* tp_iter */
|
||||||
|
@ -290,9 +296,9 @@ PyTypeObject _PyNamespace_Type = {
|
||||||
0, /* tp_descr_get */
|
0, /* tp_descr_get */
|
||||||
0, /* tp_descr_set */
|
0, /* tp_descr_set */
|
||||||
offsetof(_PyNamespaceObject, ns_dict), /* tp_dictoffset */
|
offsetof(_PyNamespaceObject, ns_dict), /* tp_dictoffset */
|
||||||
(initproc)namespace_init, /* tp_init */
|
namespace_init, /* tp_init */
|
||||||
PyType_GenericAlloc, /* tp_alloc */
|
PyType_GenericAlloc, /* tp_alloc */
|
||||||
(newfunc)namespace_new, /* tp_new */
|
namespace_new, /* tp_new */
|
||||||
PyObject_GC_Del, /* tp_free */
|
PyObject_GC_Del, /* tp_free */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue