From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Fri, 21 Feb 2025 14:56:39 +0000 (+0100) Subject: [3.13] gh-111609: Test `end_offset` in SyntaxError subclass (GH-127830) (#130407) X-Git-Tag: v3.13.3~234 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cb8d89d2e41f3d6574a17b44fe14539a54a0d81e;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-111609: Test `end_offset` in SyntaxError subclass (GH-127830) (#130407) Co-authored-by: Nice Zombies --- diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index c6fb848b8d7f..c91f66629483 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -2253,6 +2253,21 @@ class SyntaxErrorTests(unittest.TestCase): self.assertIn(expected, err.getvalue()) the_exception = exc + def test_subclass(self): + class MySyntaxError(SyntaxError): + pass + + try: + raise MySyntaxError("bad bad", ("bad.py", 1, 2, "abcdefg", 1, 7)) + except SyntaxError as exc: + with support.captured_stderr() as err: + sys.__excepthook__(*sys.exc_info()) + self.assertIn(""" + File "bad.py", line 1 + abcdefg + ^^^^^ +""", err.getvalue()) + def test_encodings(self): self.addCleanup(unlink, TESTFN) source = (