Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-95259: add test for traceback with angle-bracketed filename #95260

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Lib/test/test_traceback.py
Original file line number Diff line number Diff line change
@@ -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):