diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-06-12 05:25:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-12 05:25:04 (GMT) |
commit | 3fd54d4a7e604067e2bc0f8cfd58bdbdc09fa7f4 (patch) | |
tree | a36010810577629101ec074cf56a5c9d307acda3 /Lib/test/test_atexit.py | |
parent | 1dbce04d0e3e93b715eb0d8024da396361759d16 (diff) | |
download | cpython-3fd54d4a7e604067e2bc0f8cfd58bdbdc09fa7f4.zip cpython-3fd54d4a7e604067e2bc0f8cfd58bdbdc09fa7f4.tar.gz cpython-3fd54d4a7e604067e2bc0f8cfd58bdbdc09fa7f4.tar.bz2 |
bpo-28994: Fixed errors handling in atexit._run_exitfuncs(). (#2034)
The traceback no longer displayed for SystemExit raised in a callback registered by atexit.
Diffstat (limited to 'Lib/test/test_atexit.py')
-rw-r--r-- | Lib/test/test_atexit.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_atexit.py b/Lib/test/test_atexit.py index c761076..1d0b018 100644 --- a/Lib/test/test_atexit.py +++ b/Lib/test/test_atexit.py @@ -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(): |