]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-95259: add test for traceback with angle-bracketed filename (GH-95260)
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>
Tue, 26 Jul 2022 13:34:46 +0000 (14:34 +0100)
committerGitHub <noreply@github.com>
Tue, 26 Jul 2022 13:34:46 +0000 (14:34 +0100)
Lib/test/test_traceback.py

index ef08b29c6d360da0af2b92be5655d32d93bfc505..2089050cadfc2c9971d136015dc09188ea295128 100644 (file)
@@ -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):