[Python-checkins] gh-95259: add test for traceback with angle-bracketed filename (GH-95260)

iritkatriel webhook-mailer at python.org
Tue Jul 26 09:34:52 EDT 2022


https://github.com/python/cpython/commit/8660604b3e10aedd84f5e2d4caf3c541646102eb
commit: 8660604b3e10aedd84f5e2d4caf3c541646102eb
branch: main
author: Irit Katriel <1055913+iritkatriel at users.noreply.github.com>
committer: iritkatriel <1055913+iritkatriel at users.noreply.github.com>
date: 2022年07月26日T14:34:46+01:00
summary:
gh-95259: add test for traceback with angle-bracketed filename (GH-95260)
files:
M Lib/test/test_traceback.py
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index ef08b29c6d360..2089050cadfc2 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -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):


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /