summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_signal.py5
-rw-r--r--Modules/signalmodule.c21
2 files changed, 12 insertions, 14 deletions
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
index a00e2d8..7aa03ef 100644
--- a/Lib/test/test_signal.py
+++ b/Lib/test/test_signal.py
@@ -9,9 +9,8 @@ import subprocess
import traceback
import sys, os, time, errno
-if sys.platform == 'os2' or sys.platform == 'riscos':
- raise unittest.SkipTest("Can't test signal on %s" % \
- sys.platform)
+if sys.platform in ('os2', 'riscos'):
+ raise unittest.SkipTest("Can't test signal on %s" % sys.platform)
class HandlerBCalled(Exception):
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