summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_traceback.py
diff options
context:
space:
mode:
authorJérome Perrin <perrinjerome@gmail.com>2024-01-16 09:49:24 (GMT)
committerGitHub <noreply@github.com>2024-01-16 09:49:24 (GMT)
commit04fabe22dd98b4d87f672254b743fbadd5206352 (patch)
tree3b86f3fbf608fde8b40ffe871337068159e4631c /Lib/test/test_traceback.py
parent17b73ab99ef12f89d41acec7500a244e68b1aaa4 (diff)
downloadcpython-04fabe22dd98b4d87f672254b743fbadd5206352.zip
cpython-04fabe22dd98b4d87f672254b743fbadd5206352.tar.gz
cpython-04fabe22dd98b4d87f672254b743fbadd5206352.tar.bz2
gh-113358: Fix rendering tracebacks with exceptions with a broken __getattr__ (GH-113359)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_traceback.py')
-rw-r--r--Lib/test/test_traceback.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index a670811..372fc48 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -2209,6 +2209,20 @@ class BaseExceptionReportingTests:
err_msg = "b'please do not show me as numbers'"
self.assertEqual(self.get_report(e), vanilla + err_msg + '\n')
+ # an exception with a broken __getattr__ raising a non expected error
+ class BrokenException(Exception):
+ broken = False
+ def __getattr__(self, name):
+ if self.broken:
+ raise ValueError(f'no {name}')
+
+ e = BrokenException(123)
+ vanilla = self.get_report(e)
+ e.broken = True
+ self.assertEqual(
+ self.get_report(e),
+ vanilla + "Ignored error getting __notes__: ValueError('no __notes__')\n")
+
def test_exception_with_multiple_notes(self):
for e in [ValueError(42), SyntaxError('bad syntax')]:
with self.subTest(e=e):