Skip to content

Commit ccaea52

Browse files
vstinnerYhg1s
authored andcommitted
Revert "bpo-33418: Add tp_clear for function object (GH-8058)" (GH-15826)
This reverts commit 3c45240.
1 parent fdd17ab commit ccaea52

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

Objects/funcobject.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -570,31 +570,23 @@ func_new_impl(PyTypeObject *type, PyCodeObject *code, PyObject *globals,
570570
return (PyObject *)newfunc;
571571
}
572572

573-
static int
574-
func_clear(PyFunctionObject *op)
575-
{
576-
Py_CLEAR(op->func_code);
577-
Py_CLEAR(op->func_globals);
578-
Py_CLEAR(op->func_module);
579-
Py_CLEAR(op->func_name);
580-
Py_CLEAR(op->func_defaults);
581-
Py_CLEAR(op->func_kwdefaults);
582-
Py_CLEAR(op->func_doc);
583-
Py_CLEAR(op->func_dict);
584-
Py_CLEAR(op->func_closure);
585-
Py_CLEAR(op->func_annotations);
586-
Py_CLEAR(op->func_qualname);
587-
return 0;
588-
}
589-
590573
static void
591574
func_dealloc(PyFunctionObject *op)
592575
{
593576
_PyObject_GC_UNTRACK(op);
594-
if (op->func_weakreflist != NULL) {
577+
if (op->func_weakreflist != NULL)
595578
PyObject_ClearWeakRefs((PyObject *) op);
596-
}
597-
(void)func_clear(op);
579+
Py_DECREF(op->func_code);
580+
Py_DECREF(op->func_globals);
581+
Py_XDECREF(op->func_module);
582+
Py_DECREF(op->func_name);
583+
Py_XDECREF(op->func_defaults);
584+
Py_XDECREF(op->func_kwdefaults);
585+
Py_XDECREF(op->func_doc);
586+
Py_XDECREF(op->func_dict);
587+
Py_XDECREF(op->func_closure);
588+
Py_XDECREF(op->func_annotations);
589+
Py_XDECREF(op->func_qualname);
598590
PyObject_GC_Del(op);
599591
}
600592

@@ -669,7 +661,7 @@ PyTypeObject PyFunction_Type = {
669661
Py_TPFLAGS_METHOD_DESCRIPTOR, /* tp_flags */
670662
func_new__doc__, /* tp_doc */
671663
(traverseproc)func_traverse, /* tp_traverse */
672-
(inquiry)func_clear, /* tp_clear */
664+
0, /* tp_clear */
673665
0, /* tp_richcompare */
674666
offsetof(PyFunctionObject, func_weakreflist), /* tp_weaklistoffset */
675667
0, /* tp_iter */

0 commit comments

Comments
 (0)