https://github.com/python/cpython/commit/d9ad171ced9b4814e22fe0b078d197de86c1393d
commit: d9ad171ced9b4814e22fe0b078d197de86c1393d
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-05-15T21:32:10+02:00
summary:

gh-149879: Fix test_signal on Cygwin (#149896)

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

files:
M Lib/signal.py
M Lib/test/test_signal.py

diff --git a/Lib/signal.py b/Lib/signal.py
index c8cd3d4f597ca5..6387e5c35dbaba 100644
--- a/Lib/signal.py
+++ b/Lib/signal.py
@@ -15,7 +15,7 @@
         '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'))
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
index d6cc22558ec4fa..2cad18a69ff7c0 100644
--- a/Lib/test/test_signal.py
+++ b/Lib/test/test_signal.py
@@ -833,6 +833,8 @@ def test_itimer_real(self):
     # 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 @@ def test_itimer_virtual(self):
         # 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)

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to