File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -695,8 +695,13 @@ PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */
695695# define Py_NotImplemented (&_Py_NotImplementedStruct)
696696#endif
697697
698- /* Macro for returning Py_NotImplemented from a function */
699- #define Py_RETURN_NOTIMPLEMENTED return Py_NotImplemented
698+ /* Macro for returning Py_NotImplemented from a function. Only treat
699+ * Py_NotImplemented as immortal in the limited C API 3.12 and newer. */
700+ #if defined(Py_LIMITED_API ) && Py_LIMITED_API + 0 < 0x030c0000
701+ # define Py_RETURN_NOTIMPLEMENTED return Py_NewRef(Py_NotImplemented)
702+ #else
703+ # define Py_RETURN_NOTIMPLEMENTED return Py_NotImplemented
704+ #endif
700705
701706/* Rich comparison opcodes */
702707#define Py_LT 0
Original file line number Diff line number Diff line change 1+ Fix :c:macro: `Py_RETURN_NOTIMPLEMENTED ` in limited C API 3.11 and older:
2+ don't treat ``Py_NotImplemented `` as immortal. Patch by Victor Stinner.
You can’t perform that action at this time.
0 commit comments