]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-134989: Implement PyObject_DelAttr() as a macro in the limited C API (GH-135021)
authorVictor Stinner <vstinner@python.org>
Wed, 4 Jun 2025 13:07:52 +0000 (15:07 +0200)
committerGitHub <noreply@github.com>
Wed, 4 Jun 2025 13:07:52 +0000 (15:07 +0200)
Include/abstract.h
Misc/NEWS.d/next/C_API/2025-06-02-13-19-22.gh-issue-134989.sDDyBN.rst [new file with mode: 0644]

index b9199fc03a399a82dcb5b42fca6f36332f64f605..80f3298701d249ea2bfcb3a36c4bb2fd1b4fe17f 100644 (file)
@@ -138,7 +138,12 @@ extern "C" {
    Delete attribute named attr_name, for object o. Returns
    -1 on failure.
 
-   This is the equivalent of the Python statement: del o.attr_name. */
+   This is the equivalent of the Python statement: del o.attr_name.
+
+   Implemented as a macro in the limited C API 3.12 and older. */
+#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030d0000
+#  define PyObject_DelAttrString(O, A) PyObject_SetAttrString((O), (A), NULL)
+#endif
 
 
 /* Implemented elsewhere:
@@ -147,7 +152,12 @@ extern "C" {
 
    Delete attribute named attr_name, for object o. Returns -1
    on failure.  This is the equivalent of the Python
-   statement: del o.attr_name. */
+   statement: del o.attr_name.
+
+   Implemented as a macro in the limited C API 3.12 and older. */
+#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030d0000
+#  define PyObject_DelAttr(O, A) PyObject_SetAttr((O), (A), NULL)
+#endif
 
 
 /* Implemented elsewhere:
diff --git a/Misc/NEWS.d/next/C_API/2025-06-02-13-19-22.gh-issue-134989.sDDyBN.rst b/Misc/NEWS.d/next/C_API/2025-06-02-13-19-22.gh-issue-134989.sDDyBN.rst
new file mode 100644 (file)
index 0000000..e49f765
--- /dev/null
@@ -0,0 +1,2 @@
+Implement :c:func:`PyObject_DelAttr` and :c:func:`PyObject_DelAttrString` as
+macros in the limited C API 3.12 and older. Patch by Victor Stinner.