gh-102056: Fix a few bugs in error handling of exception printing code (#102078)

This commit is contained in:
Irit Katriel 2023-02-20 22:16:09 +00:00 committed by GitHub
parent 4d3bc89a3f
commit 022b44f254
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 7 deletions

View file

@ -1523,6 +1523,37 @@ class ThreadingExceptionTests(BaseTestCase):
self.assertEqual(out, b'')
self.assertNotIn("Unhandled exception", err.decode())
def test_print_exception_gh_102056(self):
# This used to crash. See gh-102056.
script = r"""if True:
import time
import threading
import _thread
def f():
try:
f()
except RecursionError:
f()
def g():
try:
raise ValueError()
except* ValueError:
f()
def h():
time.sleep(1)
_thread.interrupt_main()
t = threading.Thread(target=h)
t.start()
g()
t.join()
"""
assert_python_failure("-c", script)
def test_bare_raise_in_brand_new_thread(self):
def bare_raise():
raise