diff options
| author | Carey Metcalfe <carey@cmetcalfe.ca> | 2023-05-01 07:32:04 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-01 07:32:04 (GMT) |
| commit | 487f55d5801a9ae7d79d37e259e8c377c9acd39b (patch) | |
| tree | 75fec7a70ef0819fca6769c0c20aa1b552eea70f /Lib/test/test_traceback.py | |
| parent | 93107aa2a49a9354ffb10b3cd263dc3e99ebdeff (diff) | |
| download | cpython-487f55d5801a9ae7d79d37e259e8c377c9acd39b.zip cpython-487f55d5801a9ae7d79d37e259e8c377c9acd39b.tar.gz cpython-487f55d5801a9ae7d79d37e259e8c377c9acd39b.tar.bz2 | |
gh-103895: Improve how invalid `Exception.__notes__` are displayed (#103897)
Diffstat (limited to 'Lib/test/test_traceback.py')
| -rw-r--r-- | Lib/test/test_traceback.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index 5e2b353..19a2be8 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -1539,11 +1539,11 @@ class BaseExceptionReportingTests: e.__notes__ = BadThing() notes_repr = 'bad repr' - self.assertEqual(self.get_report(e), vanilla + notes_repr) + self.assertEqual(self.get_report(e), vanilla + notes_repr + '\n') e.__notes__ = Unprintable() err_msg = '<__notes__ repr() failed>' - self.assertEqual(self.get_report(e), vanilla + err_msg) + self.assertEqual(self.get_report(e), vanilla + err_msg + '\n') # non-string item in the __notes__ sequence e.__notes__ = [BadThing(), 'Final Note'] @@ -1555,6 +1555,14 @@ class BaseExceptionReportingTests: err_msg = '<note str() failed>' self.assertEqual(self.get_report(e), vanilla + err_msg + '\nFinal Note\n') + e.__notes__ = "please do not explode me" + err_msg = "'please do not explode me'" + self.assertEqual(self.get_report(e), vanilla + err_msg + '\n') + + e.__notes__ = b"please do not show me as numbers" + err_msg = "b'please do not show me as numbers'" + self.assertEqual(self.get_report(e), vanilla + err_msg + '\n') + def test_exception_with_note_with_multiple_notes(self): e = ValueError(42) vanilla = self.get_report(e) |
