gh-134170: Add colorization to unraisable exceptions (#134183)

Default implementation of sys.unraisablehook() now uses traceback._print_exception_bltin() to print exceptions with colorized text.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Peter Bierma 2025-08-04 10:35:00 -04:00 committed by GitHub
parent 8943bb722f
commit e8251dc0ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 55 additions and 6 deletions

View file

@ -489,6 +489,7 @@ class CmdLineTest(unittest.TestCase):
self.assertRegex(err.decode('ascii', 'ignore'), 'SyntaxError')
self.assertEqual(b'', out)
@force_not_colorized
def test_stdout_flush_at_shutdown(self):
# Issue #5319: if stdout.flush() fails at shutdown, an error should
# be printed out.