bpo-28994: Fixed errors handling in atexit._run_exitfuncs(). (#2034)

The traceback no longer displayed for SystemExit raised in a callback registered by atexit.
This commit is contained in:
Serhiy Storchaka 2017-06-12 08:25:04 +03:00 committed by GitHub
parent 1dbce04d0e
commit 3fd54d4a7e
3 changed files with 14 additions and 1 deletions

View file

@ -23,6 +23,9 @@ def raise1():
def raise2():
raise SystemError
def exit():
raise SystemExit
class GeneralTest(unittest.TestCase):
@ -76,6 +79,13 @@ class GeneralTest(unittest.TestCase):
self.assertRaises(ZeroDivisionError, atexit._run_exitfuncs)
self.assertIn("ZeroDivisionError", self.stream.getvalue())
def test_exit(self):
# be sure a SystemExit is handled properly
atexit.register(exit)
self.assertRaises(SystemExit, atexit._run_exitfuncs)
self.assertEqual(self.stream.getvalue(), '')
def test_print_tracebacks(self):
# Issue #18776: the tracebacks should be printed when errors occur.
def f():