[Python-checkins] Revert "bpo-33418: Add tp_clear for function object (GH-8058)" (GH-15826)

T. Wouters webhook-mailer at python.org
Tue Sep 10 05:57:35 EDT 2019


https://github.com/python/cpython/commit/ccaea525885e41c5f1e566bb68698847faaa82ca
commit: ccaea525885e41c5f1e566bb68698847faaa82ca
branch: 3.8
author: Victor Stinner <vstinner at redhat.com>
committer: T. Wouters <thomas at python.org>
date: 2019-09-10T02:57:31-07:00
summary:

Revert "bpo-33418: Add tp_clear for function object (GH-8058)" (GH-15826)

This reverts commit 3c452404ae178b742967589a0bb4a5ec768d76e0.

files:
M Objects/funcobject.c

diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index df5cc2d3f570..53aebf12f550 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -570,31 +570,23 @@ func_new_impl(PyTypeObject *type, PyCodeObject *code, PyObject *globals,
     return (PyObject *)newfunc;
 }
 
-static int
-func_clear(PyFunctionObject *op)
-{
-    Py_CLEAR(op->func_code);
-    Py_CLEAR(op->func_globals);
-    Py_CLEAR(op->func_module);
-    Py_CLEAR(op->func_name);
-    Py_CLEAR(op->func_defaults);
-    Py_CLEAR(op->func_kwdefaults);
-    Py_CLEAR(op->func_doc);
-    Py_CLEAR(op->func_dict);
-    Py_CLEAR(op->func_closure);
-    Py_CLEAR(op->func_annotations);
-    Py_CLEAR(op->func_qualname);
-    return 0;
-}
-
 static void
 func_dealloc(PyFunctionObject *op)
 {
     _PyObject_GC_UNTRACK(op);
-    if (op->func_weakreflist != NULL) {
+    if (op->func_weakreflist != NULL)
         PyObject_ClearWeakRefs((PyObject *) op);
-    }
-    (void)func_clear(op);
+    Py_DECREF(op->func_code);
+    Py_DECREF(op->func_globals);
+    Py_XDECREF(op->func_module);
+    Py_DECREF(op->func_name);
+    Py_XDECREF(op->func_defaults);
+    Py_XDECREF(op->func_kwdefaults);
+    Py_XDECREF(op->func_doc);
+    Py_XDECREF(op->func_dict);
+    Py_XDECREF(op->func_closure);
+    Py_XDECREF(op->func_annotations);
+    Py_XDECREF(op->func_qualname);
     PyObject_GC_Del(op);
 }
 
@@ -669,7 +661,7 @@ PyTypeObject PyFunction_Type = {
     Py_TPFLAGS_METHOD_DESCRIPTOR,               /* tp_flags */
     func_new__doc__,                            /* tp_doc */
     (traverseproc)func_traverse,                /* tp_traverse */
-    (inquiry)func_clear,                        /* tp_clear */
+    0,                                          /* tp_clear */
     0,                                          /* tp_richcompare */
     offsetof(PyFunctionObject, func_weakreflist), /* tp_weaklistoffset */
     0,                                          /* tp_iter */



More information about the Python-checkins mailing list