mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #18776: atexit callbacks now display their full traceback when they raise an exception.
This commit is contained in:
parent
4e985673bf
commit
24201d497c
3 changed files with 32 additions and 0 deletions
|
@ -74,6 +74,25 @@ class TestCase(unittest.TestCase):
|
|||
self.assertRaises(ZeroDivisionError, atexit._run_exitfuncs)
|
||||
self.assertIn("ZeroDivisionError", self.stream.getvalue())
|
||||
|
||||
def test_print_tracebacks(self):
|
||||
# Issue #18776: the tracebacks should be printed when errors occur.
|
||||
def f():
|
||||
1/0 # one
|
||||
def g():
|
||||
1/0 # two
|
||||
def h():
|
||||
1/0 # three
|
||||
atexit.register(f)
|
||||
atexit.register(g)
|
||||
atexit.register(h)
|
||||
|
||||
self.assertRaises(ZeroDivisionError, atexit._run_exitfuncs)
|
||||
stderr = self.stream.getvalue()
|
||||
self.assertEqual(stderr.count("ZeroDivisionError"), 3)
|
||||
self.assertIn("# one", stderr)
|
||||
self.assertIn("# two", stderr)
|
||||
self.assertIn("# three", stderr)
|
||||
|
||||
def test_stress(self):
|
||||
a = [0]
|
||||
def inc():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue