diff options
Diffstat (limited to 'Lib/test/test_threading.py')
-rw-r--r-- | Lib/test/test_threading.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index 6b6c4d220a..5f7c0a8801 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -181,6 +181,7 @@ class ThreadTests(BaseTestCase): ctypes = import_module("ctypes") set_async_exc = ctypes.pythonapi.PyThreadState_SetAsyncExc + set_async_exc.argtypes = (ctypes.c_ulong, ctypes.py_object) class AsyncExc(Exception): pass @@ -189,9 +190,11 @@ class ThreadTests(BaseTestCase): # First check it works when setting the exception from the same thread. tid = threading.get_ident() + self.assertIsInstance(tid, int) + self.assertGreater(tid, 0) try: - result = set_async_exc(ctypes.c_long(tid), exception) + result = set_async_exc(tid, exception) # The exception is async, so we might have to keep the VM busy until # it notices. while True: @@ -237,7 +240,7 @@ class ThreadTests(BaseTestCase): # Try a thread id that doesn't make sense. if verbose: print(" trying nonsensical thread id") - result = set_async_exc(ctypes.c_long(-1), exception) + result = set_async_exc(-1, exception) self.assertEqual(result, 0) # no thread states modified # Now raise an exception in the worker thread. @@ -250,7 +253,7 @@ class ThreadTests(BaseTestCase): self.assertFalse(t.finished) if verbose: print(" attempting to raise asynch exception in worker") - result = set_async_exc(ctypes.c_long(t.id), exception) + result = set_async_exc(t.id, exception) self.assertEqual(result, 1) # one thread state modified if verbose: print(" waiting for worker to say it caught the exception") |