]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Replace PyObject_Del with PyObject_Free (#122453)
authorVictor Stinner <vstinner@python.org>
Thu, 1 Aug 2024 12:12:33 +0000 (14:12 +0200)
committerGitHub <noreply@github.com>
Thu, 1 Aug 2024 12:12:33 +0000 (14:12 +0200)
PyObject_Del() is just a alias to PyObject_Free() kept for backward
compatibility. Use directly PyObject_Free() instead.

13 files changed:
Doc/c-api/typeobj.rst
Modules/_testcapi/gc.c
Modules/_testcapimodule.c
Objects/bytearrayobject.c
Objects/bytesobject.c
Objects/codeobject.c
Objects/complexobject.c
Objects/fileobject.c
Objects/odictobject.c
Objects/rangeobject.c
Objects/typeobject.c
Objects/unicodeobject.c
Python/optimizer.c

index 0091e084308245285698576b83645da035ac398b..b7b1418df513c65edf31c19c4e5ef714b5754e45 100644 (file)
@@ -650,7 +650,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
    (doesn't have the :c:macro:`Py_TPFLAGS_BASETYPE` flag bit set), it is
    permissible to call the object deallocator directly instead of via
    :c:member:`~PyTypeObject.tp_free`.  The object deallocator should be the one used to allocate the
-   instance; this is normally :c:func:`PyObject_Del` if the instance was allocated
+   instance; this is normally :c:func:`PyObject_Free` if the instance was allocated
    using :c:macro:`PyObject_New` or :c:macro:`PyObject_NewVar`, or
    :c:func:`PyObject_GC_Del` if the instance was allocated using
    :c:macro:`PyObject_GC_New` or :c:macro:`PyObject_GC_NewVar`.
@@ -1954,7 +1954,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
    match :c:func:`PyType_GenericAlloc` and the value of the
    :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit.
 
-   For static subtypes, :c:data:`PyBaseObject_Type` uses :c:func:`PyObject_Del`.
+   For static subtypes, :c:data:`PyBaseObject_Type` uses :c:func:`PyObject_Free`.
 
 
 .. c:member:: inquiry PyTypeObject.tp_is_gc
index b472a4185a98af26a3f143c138bec3be8fa60635..7e33e0d4861e84d1e4b01de64d30f162cc38d7ee 100644 (file)
@@ -72,7 +72,7 @@ without_gc(PyObject *Py_UNUSED(self), PyObject *obj)
     if (PyType_IS_GC(tp)) {
         // Don't try this at home, kids:
         tp->tp_flags -= Py_TPFLAGS_HAVE_GC;
-        tp->tp_free = PyObject_Del;
+        tp->tp_free = PyObject_Free;
         tp->tp_traverse = NULL;
         tp->tp_clear = NULL;
     }
index 5ebcfef6143e02f7daff98df6acc7b5f92e12632..4a371a5ce33ebeb9d183a76296d8c833e4d81cae 100644 (file)
@@ -289,7 +289,7 @@ static PyTypeObject _HashInheritanceTester_Type = {
     "hashinheritancetester",            /* Name of this type */
     sizeof(PyObject),           /* Basic object size */
     0,                          /* Item size for varobject */
-    (destructor)PyObject_Del, /* tp_dealloc */
+    (destructor)PyObject_Free,  /* tp_dealloc */
     0,                          /* tp_vectorcall_offset */
     0,                          /* tp_getattr */
     0,                          /* tp_setattr */
@@ -3587,7 +3587,7 @@ static PyTypeObject matmulType = {
     0,
     0,
     PyType_GenericNew,                  /* tp_new */
-    PyObject_Del,                       /* tp_free */
+    PyObject_Free,                      /* tp_free */
 };
 
 typedef struct {
@@ -3699,7 +3699,7 @@ static PyTypeObject awaitType = {
     0,
     0,
     awaitObject_new,                    /* tp_new */
-    PyObject_Del,                       /* tp_free */
+    PyObject_Free,                      /* tp_free */
 };
 
 
index 80679f93cd4c135360eac2f89afec8a43946caff..a80e4670665a22b8e996483798195400fdc71899 100644 (file)
@@ -2426,7 +2426,7 @@ PyTypeObject PyByteArray_Type = {
     (initproc)bytearray___init__,       /* tp_init */
     PyType_GenericAlloc,                /* tp_alloc */
     PyType_GenericNew,                  /* tp_new */
-    PyObject_Del,                       /* tp_free */
+    PyObject_Free,                      /* tp_free */
 };
 
 /*********************** Bytearray Iterator ****************************/
index 459df6ceacf3a8696cbf15253e9bf294873541cf..e88b199d89f75801551acc1a7c56c5368c739d87 100644 (file)
@@ -3066,7 +3066,7 @@ PyTypeObject PyBytes_Type = {
     0,                                          /* tp_init */
     bytes_alloc,                                /* tp_alloc */
     bytes_new,                                  /* tp_new */
-    PyObject_Del,                               /* tp_free */
+    PyObject_Free,                              /* tp_free */
 };
 
 void
index d45ba5ed4a9c066883b635b3a914ec8c75d9ef1d..6423a4214bfa9c08e5743cb9a26b1c67253a3813 100644 (file)
@@ -1352,7 +1352,7 @@ PyTypeObject _PyLineIterator = {
     0,                                  /* tp_init */
     0,                                  /* tp_alloc */
     0,                                  /* tp_new */
-    PyObject_Del,                       /* tp_free */
+    PyObject_Free,                      /* tp_free */
 };
 
 static lineiterator *
@@ -1443,7 +1443,7 @@ PyTypeObject _PyPositionsIterator = {
     0,                                  /* tp_init */
     0,                                  /* tp_alloc */
     0,                                  /* tp_new */
-    PyObject_Del,                       /* tp_free */
+    PyObject_Free,                      /* tp_free */
 };
 
 static PyObject*
index 7c8a6bd9dfcd3fc289cfce25b543e26985389f50..4a8dac6c53f52954c286b832d73d89091036ae90 100644 (file)
@@ -1247,5 +1247,5 @@ PyTypeObject PyComplex_Type = {
     0,                                          /* tp_init */
     PyType_GenericAlloc,                        /* tp_alloc */
     actual_complex_new,                         /* tp_new */
-    PyObject_Del,                               /* tp_free */
+    PyObject_Free,                              /* tp_free */
 };
index bae49d367b65eeb6171e3ef91299212d9d2e561c..c377d1bb28b56feadfc75783b424880830b2e84a 100644 (file)
@@ -462,7 +462,7 @@ PyTypeObject PyStdPrinter_Type = {
     0,                                          /* tp_init */
     PyType_GenericAlloc,                        /* tp_alloc */
     0,                                          /* tp_new */
-    PyObject_Del,                               /* tp_free */
+    PyObject_Free,                              /* tp_free */
 };
 
 
index 30277aa0c23883c4269f566204eae3e7d039472d..a9b801e70c98107fa95956cedbec437605d0d5e2 100644 (file)
@@ -276,7 +276,7 @@ tp_dictoffset     (__dict__)       -                   -
 tp_init           __init__         object_init         dict_init
 tp_alloc          -                PyType_GenericAlloc (repeated)
 tp_new            __new__          object_new          dict_new
-tp_free           -                PyObject_Del        PyObject_GC_Del
+tp_free           -                PyObject_Free       PyObject_GC_Del
 ================= ================ =================== ================
 
 Relevant Methods
index 9727b4f47b53a16426298f508055cd2c016ab3fe..1318ce0319d438174eff760b8e1d957b8f82699a 100644 (file)
@@ -899,7 +899,7 @@ PyTypeObject PyRangeIter_Type = {
         sizeof(_PyRangeIterObject),             /* tp_basicsize */
         0,                                      /* tp_itemsize */
         /* methods */
-        (destructor)PyObject_Del,               /* tp_dealloc */
+        (destructor)PyObject_Free,              /* tp_dealloc */
         0,                                      /* tp_vectorcall_offset */
         0,                                      /* tp_getattr */
         0,                                      /* tp_setattr */
index 5b0a466f9134953231a3ee8ddd215ef4bbab0ade..a2d82e65b6ad9f11551a1a5c7b6f36b47bf31281 100644 (file)
@@ -7456,7 +7456,7 @@ PyTypeObject PyBaseObject_Type = {
     object_init,                                /* tp_init */
     PyType_GenericAlloc,                        /* tp_alloc */
     object_new,                                 /* tp_new */
-    PyObject_Del,                               /* tp_free */
+    PyObject_Free,                              /* tp_free */
 };
 
 
@@ -8180,7 +8180,7 @@ type_ready_inherit(PyTypeObject *type)
 
     /* Sanity check for tp_free. */
     if (_PyType_IS_GC(type) && (type->tp_flags & Py_TPFLAGS_BASETYPE) &&
-        (type->tp_free == NULL || type->tp_free == PyObject_Del))
+        (type->tp_free == NULL || type->tp_free == PyObject_Free))
     {
         /* This base class needs to call tp_free, but doesn't have
          * one, or its tp_free is for non-gc'ed objects.
index ffb879a68745b18453d2e4cd903c7e6beb393b21..12578812a762f65676303b424b27e97f007490b3 100644 (file)
@@ -15265,7 +15265,7 @@ PyTypeObject PyUnicode_Type = {
     0,                            /* tp_init */
     0,                            /* tp_alloc */
     unicode_new,                  /* tp_new */
-    PyObject_Del,                 /* tp_free */
+    PyObject_Free,                /* tp_free */
     .tp_vectorcall = unicode_vectorcall,
 };
 
index ce8a36575cde1d418256ceef70c37ae2c52ca0c2..9d0381357f2123fd787a7d7dc0062719818add25 100644 (file)
@@ -1374,7 +1374,7 @@ PyTypeObject _PyCounterOptimizer_Type = {
     .tp_itemsize = 0,
     .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION,
     .tp_methods = counter_optimizer_methods,
-    .tp_dealloc = (destructor)PyObject_Del,
+    .tp_dealloc = (destructor)PyObject_Free,
 };
 
 PyObject *