[3.14] gh-140487: Fix Py_RETURN_NOTIMPLEMENTED in limited C API 3.11 (GH-140636) (#140668)

gh-140487: Fix Py_RETURN_NOTIMPLEMENTED in limited C API 3.11 (GH-140636)

Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE have already been
fixed by commit 9258f3da91 (issue gh-134989).
(cherry picked from commit c636477523)

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Miss Islington (bot) 2025-10-27 14:15:49 +01:00 committed by GitHub
parent 87afee2312
commit ce1deb947e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View file

@ -674,8 +674,13 @@ PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */
# define Py_NotImplemented (&_Py_NotImplementedStruct)
#endif
/* Macro for returning Py_NotImplemented from a function */
#define Py_RETURN_NOTIMPLEMENTED return Py_NotImplemented
/* Macro for returning Py_NotImplemented from a function. Only treat
* Py_NotImplemented as immortal in the limited C API 3.12 and newer. */
#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030c0000
# define Py_RETURN_NOTIMPLEMENTED return Py_NewRef(Py_NotImplemented)
#else
# define Py_RETURN_NOTIMPLEMENTED return Py_NotImplemented
#endif
/* Rich comparison opcodes */
#define Py_LT 0

View file

@ -0,0 +1,2 @@
Fix :c:macro:`Py_RETURN_NOTIMPLEMENTED` in limited C API 3.11 and older:
don't treat ``Py_NotImplemented`` as immortal. Patch by Victor Stinner.