Skip to content

Commit 5c58695

Browse files
committed
Fix test_poll and add assertion in pytime.c
1 parent ebac53a commit 5c58695

2 files changed

Lines changed: 5 additions & 12 deletions

File tree

‎Lib/test/test_poll.py‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,34 +207,26 @@ def test_threaded_poll(self):
207207
@unittest.skipUnless(threading, 'Threading required for this test.')
208208
@reap_threads
209209
def test_poll_blocks_with_negative_ms(self):
210-
211210
for timeout_ms in [None, -1, -1.0, -0.1, -1e-100]:
212-
213-
# GIVEN
214-
215211
# Create two file descriptors. This will be used to unlock
216212
# the blocking call to poll.poll inside the thread
217-
218213
r, w = os.pipe()
219-
self.addCleanup(os.close, r)
220-
self.addCleanup(os.close, w)
221-
222214
pollster = select.poll()
223215
pollster.register(r, select.POLLIN)
224216

225-
# WHEN
226-
227217
poll_thread = threading.Thread(target=pollster.poll, args=(timeout_ms,))
228218
poll_thread.start()
229219
poll_thread.join(timeout=0.1)
230-
231-
# THEN
232220
self.assertTrue(poll_thread.is_alive())
233221

234222
# Write to the pipe so pollster.poll unblocks and the thread ends.
235223
os.write(w, b'spam')
236224
poll_thread.join()
237225
self.assertFalse(poll_thread.is_alive())
226+
os.close(r)
227+
os.close(w)
228+
229+
238230

239231

240232

‎Python/pytime.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ _PyTime_Round(double x, _PyTime_round_t round)
103103
d = floor(d);
104104
}
105105
else {
106+
assert(round == _PyTime_ROUND_UP);
106107
d = (d < 0.0) ? floor(d) : ceil(d);
107108
}
108109
return d;

0 commit comments

Comments
 (0)