https://github.com/python/cpython/commit/02e5880da4ba3e78969babfac7f14601c7f410e3 commit: 02e5880da4ba3e78969babfac7f14601c7f410e3 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ambv <[email protected]> date: 2026-07-22T14:21:19+02:00 summary:
[3.13] gh-154137: Fix handle leak in test_winapi (GH-154201) (#154204) gh-154137: Fix handle leak in test_winapi (GH-154201) Make sure that events handles are closed. (cherry picked from commit 1f9d20bbd4fed601e7caf76a12e52d35c8ae2b14) Co-authored-by: Victor Stinner <[email protected]> files: M Lib/test/test_winapi.py diff --git a/Lib/test/test_winapi.py b/Lib/test/test_winapi.py index 73b8228ddc97ba..b7e8659e63e2ba 100644 --- a/Lib/test/test_winapi.py +++ b/Lib/test/test_winapi.py @@ -14,9 +14,16 @@ MAXIMUM_WAIT_OBJECTS = 64 MAXIMUM_BATCHED_WAIT_OBJECTS = (MAXIMUM_WAIT_OBJECTS - 1) ** 2 + +def close_events(events): + for handle in events: + _winapi.CloseHandle(handle) + + class WinAPIBatchedWaitForMultipleObjectsTests(unittest.TestCase): def _events_waitall_test(self, n): evts = [_winapi.CreateEventW(0, False, False, None) for _ in range(n)] + self.addCleanup(close_events, evts) with self.assertRaises(TimeoutError): _winapi.BatchedWaitForMultipleObjects(evts, True, 100) @@ -44,6 +51,7 @@ def _events_waitall_test(self, n): def _events_waitany_test(self, n): evts = [_winapi.CreateEventW(0, False, False, None) for _ in range(n)] + self.addCleanup(close_events, evts) with self.assertRaises(TimeoutError): _winapi.BatchedWaitForMultipleObjects(evts, False, 100) _______________________________________________ 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]
