]> granicus.if.org Git - python/commitdiff
Merged revisions 84556 via svnmerge from
authorBrian Curtin <brian.curtin@gmail.com>
Mon, 6 Sep 2010 16:10:04 +0000 (16:10 +0000)
committerBrian Curtin <brian.curtin@gmail.com>
Mon, 6 Sep 2010 16:10:04 +0000 (16:10 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r84556 | brian.curtin | 2010-09-06 11:04:10 -0500 (Mon, 06 Sep 2010) | 7 lines

  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.
........

Lib/test/test_signal.py
Modules/signalmodule.c

index a00e2d8621133adc6a2cd4ccc5a24d6b2643c968..7aa03ef8920561bc33b73365a904f3cadda0d266 100644 (file)
@@ -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):
index e9abec437de583d165bbec204a0b4951583cbfba..c2e762abbe8bf89a76694165cf512bf6e101c419 100644 (file)
@@ -252,21 +252,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