-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
bpo-23325: Fix SIG_IGN and SIG_DFL int comparison in signal module #31759
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
Conversation
1f535e0
to
3438104
Compare
Modules/signalmodule.c
Outdated
@@ -1893,7 +1911,15 @@ PyErr_SetInterruptEx(int signum) | |||
|
|||
signal_state_t *state = &signal_global_state; | |||
PyObject *func = get_handler(signum); | |||
if (func != state->ignore_handler && func != state->default_handler) { | |||
int is_ign = PyObject_RichCompareBool(func, state->ignore_handler, Py_EQ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it okay to call a Python code in PyErr_SetInterruptEx()
?
If func
is a custom callable, it can have an __eq__
method which can call an arbitrary Python code here.
It may be safer to use PyLong_Check()
+ PyLong_GetLongAndOverflow()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
I took a different approach and added a helper function. We can safely assume that the internal handler objects are always exact longs. Comparison between exact longs should never fail.
67876c2
to
cc4df05
Compare
Thanks @tiran for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10. |
Sorry, @tiran, I could not cleanly backport this to |
GH-31768 is a backport of this pull request to the 3.10 branch. |
…ythonGH-31759) (cherry picked from commit c8a47e7) Co-authored-by: Christian Heimes <[email protected]>
…H-31759) (cherry picked from commit c8a47e7) Co-authored-by: Christian Heimes <[email protected]>
https://bugs.python.org/issue23325
Automerge-Triggered-By: GH:tiran