Skip to content

_selectmodule.c does not handle errors when creating a module #111233

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
sobolevn opened this issue Oct 23, 2023 · 1 comment
Closed

_selectmodule.c does not handle errors when creating a module #111233

sobolevn opened this issue Oct 23, 2023 · 1 comment
Assignees
Labels
extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Oct 23, 2023

Bug report

It is documented that PyModule_AddIntMacro can raise an error (and it can in fact):

.. c:macro:: PyModule_AddIntMacro(module, macro)

   Return ``-1`` on error, ``0`` on success.

But, some calls are not checked for errors:

cpython/Modules/selectmodule.c

Lines 2471 to 2476 in 96cbd1e

PyModule_AddIntMacro(m, POLLIN);
PyModule_AddIntMacro(m, POLLPRI);
PyModule_AddIntMacro(m, POLLOUT);
PyModule_AddIntMacro(m, POLLERR);
PyModule_AddIntMacro(m, POLLHUP);
PyModule_AddIntMacro(m, POLLNVAL);

Linked PRs

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error extension-modules C modules in the Modules dir labels Oct 23, 2023
@sobolevn sobolevn self-assigned this Oct 23, 2023
sobolevn added a commit to sobolevn/cpython that referenced this issue Oct 23, 2023
erlend-aasland pushed a commit that referenced this issue Oct 25, 2023
Introduce ADD_INT macro wrapper for PyModule_AddIntConstant()
@hugovk
Copy link
Member

hugovk commented Nov 9, 2023

Thanks!

@hugovk hugovk closed this as completed Nov 9, 2023
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
…ython#111234)

Introduce ADD_INT macro wrapper for PyModule_AddIntConstant()
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
…ython#111234)

Introduce ADD_INT macro wrapper for PyModule_AddIntConstant()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants
@hugovk @sobolevn and others