From aa829e1c0e81fd3087650ea32a42ca5e57b93504 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: 2026年1月13日 12:38:31 +0100 Subject: [PATCH 1/3] gh-141004: Mark up docs of old PyMem macros Their docs-only deprecation notice appeared 2.0: https://docs.python.org/release/2.0/api/memoryInterface.html but not 1.6: https://docs.python.org/release/2.0/api/memoryInterface.html Nowadays we call this soft deprecation. Since PEP 445, they are now direct aliases; there are no (additional) binary compatibility concerns over the preferred names. --- Doc/c-api/memory.rst | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/Doc/c-api/memory.rst b/Doc/c-api/memory.rst index 2395898010214d..1f042fe8d93ad1 100644 --- a/Doc/c-api/memory.rst +++ b/Doc/c-api/memory.rst @@ -293,17 +293,23 @@ The following type-oriented macros are provided for convenience. Note that Same as :c:func:`PyMem_Free`. -In addition, the following macro sets are provided for calling the Python memory -allocator directly, without involving the C API functions listed above. However, -note that their use does not preserve binary compatibility across Python -versions and is therefore deprecated in extension modules. - -* ``PyMem_MALLOC(size)`` -* ``PyMem_NEW(type, size)`` -* ``PyMem_REALLOC(ptr, size)`` -* ``PyMem_RESIZE(ptr, type, size)`` -* ``PyMem_FREE(ptr)`` -* ``PyMem_DEL(ptr)`` +.. c:macro:: PyMem_MALLOC(size) + PyMem_NEW(type, size) + PyMem_REALLOC(ptr, size) + PyMem_RESIZE(ptr, type, size) + PyMem_FREE(ptr) + PyMem_DEL(ptr) + + These macros are :term:`soft deprecated` aliases for the APIs above, + provided for backwards compatibility. + + .. versionchanged:: 3.4 + + The macros are now aliases of the corresponding mixed-case names. + Previously, their of the macros was the same, but their use did + not preserve binary compatibility across Python versions. + + .. deprecated:: 2.0 .. _objectinterface: From 5a1e6fe89c29f61d0f880f7db8ed3e5063f61f60 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: 2026年1月13日 19:04:33 +0100 Subject: [PATCH 2/3] Fix bad edit --- Doc/c-api/memory.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/memory.rst b/Doc/c-api/memory.rst index 1f042fe8d93ad1..626ea5ae014a54 100644 --- a/Doc/c-api/memory.rst +++ b/Doc/c-api/memory.rst @@ -306,7 +306,7 @@ The following type-oriented macros are provided for convenience. Note that .. versionchanged:: 3.4 The macros are now aliases of the corresponding mixed-case names. - Previously, their of the macros was the same, but their use did + Previously, their behavior was the same, but their use did not preserve binary compatibility across Python versions. .. deprecated:: 2.0 From dccb9ac9c72eb49fffd01c6b849d9d0c8458a046 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: 2026年1月14日 13:58:22 +0100 Subject: [PATCH 3/3] Use a table --- Doc/c-api/memory.rst | 48 +++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/Doc/c-api/memory.rst b/Doc/c-api/memory.rst index 626ea5ae014a54..a3be75a2a76d60 100644 --- a/Doc/c-api/memory.rst +++ b/Doc/c-api/memory.rst @@ -293,23 +293,39 @@ The following type-oriented macros are provided for convenience. Note that Same as :c:func:`PyMem_Free`. -.. c:macro:: PyMem_MALLOC(size) - PyMem_NEW(type, size) - PyMem_REALLOC(ptr, size) - PyMem_RESIZE(ptr, type, size) - PyMem_FREE(ptr) - PyMem_DEL(ptr) - These macros are :term:`soft deprecated` aliases for the APIs above, - provided for backwards compatibility. - - .. versionchanged:: 3.4 - - The macros are now aliases of the corresponding mixed-case names. - Previously, their behavior was the same, but their use did - not preserve binary compatibility across Python versions. - - .. deprecated:: 2.0 +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 + * Corresponding function or macro + * * .. c:macro:: PyMem_MALLOC(size) + * :c:func:`PyMem_Malloc` + * * .. c:macro:: PyMem_NEW(type, size) + * :c:macro:`PyMem_New` + * * .. c:macro:: PyMem_REALLOC(ptr, size) + * :c:func:`PyMem_Realloc` + * * .. c:macro:: PyMem_RESIZE(ptr, type, size) + * :c:macro:`PyMem_Resize` + * * .. c:macro:: PyMem_FREE(ptr) + * :c:func:`PyMem_Free` + * * .. c:macro:: PyMem_DEL(ptr) + * :c:func:`PyMem_Free` + +.. versionchanged:: 3.4 + + The macros are now aliases of the corresponding functions and macros. + Previously, their behavior was the same, but their use did not necessarily + preserve binary compatibility across Python versions. + +.. deprecated:: 2.0 .. _objectinterface:

AltStyle によって変換されたページ (->オリジナル) /