Skip to content

Commit

Permalink
gh-95259: add test for traceback with angle-bracketed filename (GH-95260
Browse files Browse the repository at this point in the history
)
  • Loading branch information
iritkatriel committed Jul 26, 2022
1 parent b1f648e commit 8660604
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Lib/test/test_traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,21 @@ def __str__(self):
exp = "%s: %s\n" % (str_name, str_value)
self.assertEqual(exp, err)

def test_exception_angle_bracketed_filename(self):
src = textwrap.dedent("""
try:
raise ValueError(42)
except Exception as e:
exc = e
""")

code = compile(src, "<does not exist>", "exec")
g, l = {}, {}
exec(code, g, l)
err = self.get_report(l['exc'])
exp = ' File "<does not exist>", line 3, in <module>\nValueError: 42\n'
self.assertIn(exp, err)

def test_exception_modulename_not_unicode(self):
class X(Exception):
def __str__(self):
Expand Down

0 comments on commit 8660604

Please sign in to comment.