summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2022-07-26 13:34:46 (GMT)
committerGitHub <noreply@github.com>2022-07-26 13:34:46 (GMT)
commit8660604b3e10aedd84f5e2d4caf3c541646102eb (patch)
tree7bb9bface3a272cdfe715abb0ca45ffcb45c725d
parentb1f648efc56ff17e18ec2b7402d59a771b305004 (diff)
downloadcpython-8660604b3e10aedd84f5e2d4caf3c541646102eb.zip
cpython-8660604b3e10aedd84f5e2d4caf3c541646102eb.tar.gz
cpython-8660604b3e10aedd84f5e2d4caf3c541646102eb.tar.bz2
gh-95259: add test for traceback with angle-bracketed filename (GH-95260)
-rw-r--r--Lib/test/test_traceback.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index ef08b29..2089050 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -1477,6 +1477,21 @@ class BaseExceptionReportingTests:
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):