Skip to content

Py_RETURN_NOTIMPLEMENTED should INCREF on stable API 3.11 #140487

@hpkfft

Description

@hpkfft

Bug report

Bug description:

In object.h, I believe

#define Py_RETURN_NOTIMPLEMENTED return Py_NOTIMPLEMENTED

should be

#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

and Py_NotImplemented should add Changed in version 3.12: Py_NOTIMPLEMENTED is immortal.

and Py_RETURN_NOTIMPLEMENTED should say Return Py_NotImplemented from a function. without saying it creates a new strong reference.

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions