summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrian Curtin <brian.curtin@gmail.com>2010-09-06 16:04:10 (GMT)
committerBrian Curtin <brian.curtin@gmail.com>2010-09-06 16:04:10 (GMT)
commitc734b312cb8316af0c036323b16caf23545cd21f (patch)
treee8b23e51e9b39c86e7101af251dc4b57fabb5cc7 /Modules
parent92f87f7c49179e271e893898ec898f9908508313 (diff)
downloadcpython-c734b312cb8316af0c036323b16caf23545cd21f.zip
cpython-c734b312cb8316af0c036323b16caf23545cd21f.tar.gz
cpython-c734b312cb8316af0c036323b16caf23545cd21f.tar.bz2
Clean up the fix to #9324 with some of the suggestions raised on python-dev
in response to the original checkin. Move the validation from the original loop into a switch statement, and adjust a platform check in the tests.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/signalmodule.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index b5846fa..8b60e41 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -255,21 +255,20 @@ signal_signal(PyObject *self, PyObject *args)
int sig_num;
PyObject *old_handler;
void (*func)(int);
-#ifdef MS_WINDOWS
- int cur_sig, num_valid_sigs = 6;
- static int valid_sigs[] = {SIGABRT, SIGFPE, SIGILL, SIGINT,
- SIGSEGV, SIGTERM};
- BOOL valid_sig = FALSE;
-#endif
if (!PyArg_ParseTuple(args, "iO:signal", &sig_num, &obj))
return NULL;
#ifdef MS_WINDOWS
/* Validate that sig_num is one of the allowable signals */
- for (cur_sig = 0; cur_sig < num_valid_sigs; cur_sig++)
- valid_sig |= (sig_num == valid_sigs[cur_sig]);
- if (!valid_sig) {
- PyErr_SetString(PyExc_ValueError, "signal number out of range");
- return NULL;
+ switch (sig_num) {
+ case SIGABRT: break;
+ case SIGFPE: break;
+ case SIGILL: break;
+ case SIGINT: break;
+ case SIGSEGV: break;
+ case SIGTERM: break;
+ default:
+ PyErr_SetString(PyExc_ValueError, "invalid signal value");
+ return NULL;
}
#endif
#ifdef WITH_THREAD