Skip to content

Discrepancy in docs for PyModule_AddObjectRef #121749

Closed

Description

@tomasr8

Bug report

Bug description:

The docs for PyModule_AddObjectRef say:

Return ``NULL`` if *value* is ``NULL``. It must be called with an exception
raised in this case.

However the function actually returns -1 in that case:

cpython/Python/modsupport.c

Lines 590 to 597 in cae1526

if (!value) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_SystemError,
"PyModule_AddObjectRef() must be called "
"with an exception raised if value is NULL");
}
return -1;
}

We should update the documentation to reflect that.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

  1. GovernmentPlates commented on Jul 14, 2024

    @GovernmentPlates
    Contributor

    On it

  2. added a commit that references this issue on Jul 14, 2024
  3. added 2 commits that reference this issue on Jul 14, 2024
  4. added 2 commits that reference this issue on Jul 14, 2024
  5. encukou commented on Jul 14, 2024

    @encukou
    Member

    Thank you @tomasr8 for the report and @GovernmentPlates for the fix!

  6. added a commit that references this issue on Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions