Message411104
| Author |
christian.heimes |
| Recipients |
barry, christian.heimes, eli.bendersky, giampaolo.rodola, serhiy.storchaka, vstinner, xiang.zhang |
| Date |
2022年01月21日.09:54:27 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1642758867.97.0.785553426968.issue23325@roundup.psfhosted.org> |
| In-reply-to |
| Content |
Understood, thanks!
A trivial fix for the integer comparison bug would solve my issue:
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -527,21 +527,20 @@ signal_signal_impl(PyObject *module, int signalnum, PyObject *handler)
"signal number out of range");
return NULL;
}
- if (handler == modstate->ignore_handler) {
+ if (PyCallable_Check(handler)) {
+ func = signal_handler;
+ }
+ else if (PyObject_RichCompareBool(handler, modstate->ignore_handler, Py_EQ) == 1) {
func = SIG_IGN;
}
- else if (handler == modstate->default_handler) {
+ else if (PyObject_RichCompareBool(handler, modstate->default_handler, Py_EQ) == 1) {
func = SIG_DFL;
- }
- else if (!PyCallable_Check(handler)) {
+ } else {
_PyErr_SetString(tstate, PyExc_TypeError,
"signal handler must be signal.SIG_IGN, "
"signal.SIG_DFL, or a callable object");
return NULL;
}
- else {
- func = signal_handler;
- }
/* Check for pending signals before changing signal handler */
if (_PyErr_CheckSignalsTstate(tstate)) { |
|