]> granicus.if.org Git - python/commitdiff
Close #18396: fix spurious test_signal failure on Windows
authorNick Coghlan <ncoghlan@gmail.com>
Sat, 3 Aug 2013 12:56:30 +0000 (22:56 +1000)
committerNick Coghlan <ncoghlan@gmail.com>
Sat, 3 Aug 2013 12:56:30 +0000 (22:56 +1000)
signal.getsignal returns None for some signals if faulthandler
is enabled (Patch by Jeremy Kloth)

Lib/test/test_signal.py
Misc/NEWS

index 1ef764332449cb3f9458de78e9bcf405078ab7e2..9b4ba5016ee400e4f087215b55ff997889a08afc 100644 (file)
@@ -209,11 +209,17 @@ class WindowsSignalTests(unittest.TestCase):
     def test_issue9324(self):
         # Updated for issue #10003, adding SIGBREAK
         handler = lambda x, y: None
+        checked = set()
         for sig in (signal.SIGABRT, signal.SIGBREAK, signal.SIGFPE,
                     signal.SIGILL, signal.SIGINT, signal.SIGSEGV,
                     signal.SIGTERM):
-            # Set and then reset a handler for signals that work on windows
-            signal.signal(sig, signal.signal(sig, handler))
+            # Set and then reset a handler for signals that work on windows.
+            # Issue #18396, only for signals without a C-level handler.
+            if signal.getsignal(sig) is not None:
+                signal.signal(sig, signal.signal(sig, handler))
+                checked.add(sig)
+        # Issue #18396: Ensure the above loop at least tested *something*
+        self.assertTrue(checked)
 
         with self.assertRaises(ValueError):
             signal.signal(-1, handler)
index 98357a4411bd402a9a0bbae47ebda67cfabf7442..bd856962e047e68f53cf7f9ef0bd2091612e1d57 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -230,6 +230,9 @@ IDLE
 Tests
 -----
 
+- Issue #18396: Fix spurious test failure in test_signal on Windows when
+  faulthandler is enabled (Patch by Jeremy Kloth)
+
 - Issue #17046: Fix broken test_executable_without_cwd in test_subprocess.
 
 - Issue #15415: Add new temp_dir() and change_cwd() context managers to