From f05346e69d4f68c38174813a34da9de956442664 Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Sun, 9 Nov 2025 10:06:38 -0500 Subject: [PATCH 1/3] gh-141004: Document deprecated aliases for memory allocation (GH-141146) (cherry picked from commit 1d738dea6364de004f8cec7c6309d6bbd3b996c7) --- Doc/c-api/allocation.rst | 52 ++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/Doc/c-api/allocation.rst b/Doc/c-api/allocation.rst index b44fe983d22d88..1102f962415064 100644 --- a/Doc/c-api/allocation.rst +++ b/Doc/c-api/allocation.rst @@ -58,24 +58,34 @@ Allocating Objects on the Heap use :c:func:`PyObject_GC_NewVar` instead. -.. c:function:: void PyObject_Del(void *op) - - Releases memory allocated to an object using :c:macro:`PyObject_New` or - :c:macro:`PyObject_NewVar`. This is normally called from the - :c:member:`~PyTypeObject.tp_dealloc` handler specified in the object's type. The fields of - the object should not be accessed after this call as the memory is no - longer a valid Python object. - - -.. c:var:: PyObject _Py_NoneStruct - - Object which is visible in Python as ``None``. This should only be accessed - using the :c:macro:`Py_None` macro, which evaluates to a pointer to this - object. - - -.. seealso:: - - :ref:`moduleobjects` - To allocate and create extension modules. - +Deprecated aliases +^^^^^^^^^^^^^^^^^^ + +These are :term:`soft deprecated` aliases to existing functions and macros. +They exist solely for backwards compatibility. + + +.. list-table:: + :widths: auto + :header-rows: 1 + + * * Deprecated alias + * Function + * * .. c:macro:: PyObject_NEW(type, typeobj) + * :c:macro:`PyObject_New` + * * .. c:macro:: PyObject_NEW_VAR(type, typeobj, n) + * :c:macro:`PyObject_NewVar` + * * .. c:macro:: PyObject_INIT(op, typeobj) + * :c:func:`PyObject_Init` + * * .. c:macro:: PyObject_INIT_VAR(op, typeobj, n) + * :c:func:`PyObject_InitVar` + * * .. c:macro:: PyObject_MALLOC(n) + * :c:func:`PyObject_Malloc` + * * .. c:macro:: PyObject_REALLOC(p, n) + * :c:func:`PyObject_Realloc` + * * .. c:macro:: PyObject_FREE(p) + * :c:func:`PyObject_Free` + * * .. c:macro:: PyObject_DEL(p) + * :c:func:`PyObject_Free` + * * .. c:macro:: PyObject_Del(p) + * :c:func:`PyObject_Free` From 04f35f1352373d8e8de3fbad4aa93a12de9282a8 Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Sun, 9 Nov 2025 10:26:47 -0500 Subject: [PATCH 2/3] [3.13] gh-141004: Document deprecated aliases for memory allocation (GH-141146) (cherry picked from commit 1d738dea6364de004f8cec7c6309d6bbd3b996c7) Co-authored-by: Peter Bierma From cdffd741bfe3f787f8a9e603a61e083a49371bf1 Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Sun, 9 Nov 2025 10:28:45 -0500 Subject: [PATCH 3/3] Fix accidental code removal. --- Doc/c-api/allocation.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Doc/c-api/allocation.rst b/Doc/c-api/allocation.rst index 1102f962415064..c85db44f24e864 100644 --- a/Doc/c-api/allocation.rst +++ b/Doc/c-api/allocation.rst @@ -58,6 +58,19 @@ Allocating Objects on the Heap use :c:func:`PyObject_GC_NewVar` instead. +.. c:var:: PyObject _Py_NoneStruct + + Object which is visible in Python as ``None``. This should only be accessed + using the :c:macro:`Py_None` macro, which evaluates to a pointer to this + object. + + +.. seealso:: + + :ref:`moduleobjects` + To allocate and create extension modules. + + Deprecated aliases ^^^^^^^^^^^^^^^^^^