Skip to content

Commit 8660604

Browse files
authored
gh-95259: add test for traceback with angle-bracketed filename (GH-95260)
1 parent b1f648e commit 8660604

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Lib/test/test_traceback.py

+15
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,21 @@ def __str__(self):
14771477
exp = "%s: %s\n" % (str_name, str_value)
14781478
self.assertEqual(exp, err)
14791479

1480+
def test_exception_angle_bracketed_filename(self):
1481+
src = textwrap.dedent("""
1482+
try:
1483+
raise ValueError(42)
1484+
except Exception as e:
1485+
exc = e
1486+
""")
1487+
1488+
code = compile(src, "<does not exist>", "exec")
1489+
g, l = {}, {}
1490+
exec(code, g, l)
1491+
err = self.get_report(l['exc'])
1492+
exp = ' File "<does not exist>", line 3, in <module>\nValueError: 42\n'
1493+
self.assertIn(exp, err)
1494+
14801495
def test_exception_modulename_not_unicode(self):
14811496
class X(Exception):
14821497
def __str__(self):

0 commit comments

Comments
 (0)