Skip to content

Discrepancy in docs for PyModule_AddObjectRef #121749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tomasr8 opened this issue Jul 14, 2024 · 2 comments
Closed

Discrepancy in docs for PyModule_AddObjectRef #121749

tomasr8 opened this issue Jul 14, 2024 · 2 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@tomasr8
Copy link
Member

tomasr8 commented Jul 14, 2024

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

@tomasr8 tomasr8 added the type-bug An unexpected behavior, bug, or error label Jul 14, 2024
@GovernmentPlates
Copy link
Contributor

On it

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 14, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 14, 2024
encukou pushed a commit that referenced this issue Jul 14, 2024
encukou pushed a commit that referenced this issue Jul 14, 2024
@encukou
Copy link
Member

encukou commented Jul 14, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants