From: Victor Stinner Date: Fri, 15 May 2026 19:32:10 +0000 (+0200) Subject: gh-149879: Fix test_signal on Cygwin (#149896) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d9ad171ced9b4814e22fe0b078d197de86c1393d;p=thirdparty%2FPython%2Fcpython.git 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). --- diff --git a/Lib/signal.py b/Lib/signal.py index c8cd3d4f597c..6387e5c35dba 100644 --- a/Lib/signal.py +++ b/Lib/signal.py @@ -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')) diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py index d6cc22558ec4..2cad18a69ff7 100644 --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -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)