From 778276f962990cdadd828dc4eda5d255fd087fe2 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Mon, 11 Dec 2023 18:42:07 -0700 Subject: [PATCH] Fix TestInterpreterRun. --- Lib/test/test_interpreters/test_api.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_interpreters/test_api.py b/Lib/test/test_interpreters/test_api.py index 7f4014c28c70ef..e4ae9d005b5282 100644 --- a/Lib/test/test_interpreters/test_api.py +++ b/Lib/test/test_interpreters/test_api.py @@ -570,9 +570,19 @@ def test_success(self): self.assertEqual(out, 'it worked!') def test_failure(self): - interp = interpreters.create() - t = interp.run('raise Exception') - t.join() + caught = False + def excepthook(args): + nonlocal caught + caught = True + threading.excepthook = excepthook + try: + interp = interpreters.create() + t = interp.run('raise Exception') + t.join() + + self.assertTrue(caught) + except BaseException: + threading.excepthook = threading.__excepthook__ class TestIsShareable(TestBase):