Issue #13964: signal.sigtimedwait() timeout is now a float instead of a tuple

Add a private API to convert an int or float to a C timespec structure.
This commit is contained in:
Victor Stinner 2012-03-02 22:54:03 +01:00
parent 1c13f84f55
commit 643cd68ea4
7 changed files with 106 additions and 20 deletions

View file

@ -662,7 +662,7 @@ class PendingSignalsTests(unittest.TestCase):
self.wait_helper(signal.SIGALRM, '''
def test(signum):
signal.alarm(1)
info = signal.sigtimedwait([signum], (10, 1000))
info = signal.sigtimedwait([signum], 10.1000)
if info.si_signo != signum:
raise Exception('info.si_signo != %s' % signum)
''')
@ -675,7 +675,7 @@ class PendingSignalsTests(unittest.TestCase):
def test(signum):
import os
os.kill(os.getpid(), signum)
info = signal.sigtimedwait([signum], (0, 0))
info = signal.sigtimedwait([signum], 0)
if info.si_signo != signum:
raise Exception('info.si_signo != %s' % signum)
''')
@ -685,7 +685,7 @@ class PendingSignalsTests(unittest.TestCase):
def test_sigtimedwait_timeout(self):
self.wait_helper(signal.SIGALRM, '''
def test(signum):
received = signal.sigtimedwait([signum], (1, 0))
received = signal.sigtimedwait([signum], 1.0)
if received is not None:
raise Exception("received=%r" % (received,))
''')
@ -694,9 +694,7 @@ class PendingSignalsTests(unittest.TestCase):
'need signal.sigtimedwait()')
def test_sigtimedwait_negative_timeout(self):
signum = signal.SIGALRM
self.assertRaises(ValueError, signal.sigtimedwait, [signum], (-1, -1))
self.assertRaises(ValueError, signal.sigtimedwait, [signum], (0, -1))
self.assertRaises(ValueError, signal.sigtimedwait, [signum], (-1, 0))
self.assertRaises(ValueError, signal.sigtimedwait, [signum], -1.0)
@unittest.skipUnless(hasattr(signal, 'sigwaitinfo'),
'need signal.sigwaitinfo()')