]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-149879: Fix test_signal on Cygwin (#149896)
authorVictor Stinner <vstinner@python.org>
Fri, 15 May 2026 19:32:10 +0000 (21:32 +0200)
committerGitHub <noreply@github.com>
Fri, 15 May 2026 19:32:10 +0000 (21:32 +0200)
* Check for SIG_BLOCK instead of pthread_sigmask() to decide if
  SIG_BLOCK, SIG_UNBLOCK and SIG_SETMASK constants should be
  converted to enums.
* Skip ITIMER_VIRTUAL and ITIMER_PROF tests on Cygwin: setitimer()
  fails with ItimerError(EINVAL).

Lib/signal.py
Lib/test/test_signal.py

index c8cd3d4f597ca500947b74541d2d96be21f9627d..6387e5c35dbabac82f757c5e42a06c67e41e2b4c 100644 (file)
@@ -15,7 +15,7 @@ _IntEnum._convert_(
         'Handlers', __name__,
         lambda name: name in ('SIG_DFL', 'SIG_IGN'))
 
-if 'pthread_sigmask' in _globals:
+if 'SIG_BLOCK' in _globals:
     _IntEnum._convert_(
             'Sigmasks', __name__,
             lambda name: name in ('SIG_BLOCK', 'SIG_UNBLOCK', 'SIG_SETMASK'))
index d6cc22558ec4fafc307e8c50b3b907fbcff60f07..2cad18a69ff7c0202e4f9821f003847dac234fdb 100644 (file)
@@ -833,6 +833,8 @@ class ItimerTest(unittest.TestCase):
     # Issue 3864, unknown if this affects earlier versions of freebsd also
     @unittest.skipIf(sys.platform in ('netbsd5',) or is_apple_mobile,
         'itimer not reliable (does not mix well with threading) on some BSDs.')
+    @unittest.skipIf(sys.platform == 'cygwin',
+                     "Cygwin doesn't support ITIMER_VIRTUAL")
     def test_itimer_virtual(self):
         self.itimer = signal.ITIMER_VIRTUAL
         signal.signal(signal.SIGVTALRM, self.sig_vtalrm)
@@ -850,6 +852,8 @@ class ItimerTest(unittest.TestCase):
         # and the handler should have been called
         self.assertEqual(self.hndl_called, True)
 
+    @unittest.skipIf(sys.platform == 'cygwin',
+                     "Cygwin doesn't support ITIMER_PROF")
     def test_itimer_prof(self):
         self.itimer = signal.ITIMER_PROF
         signal.signal(signal.SIGPROF, self.sig_prof)