From cb8d89d2e41f3d6574a17b44fe14539a54a0d81e Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Fri, 21 Feb 2025 15:56:39 +0100 Subject: [PATCH] [3.13] gh-111609: Test `end_offset` in SyntaxError subclass (GH-127830) (#130407) Co-authored-by: Nice Zombies --- Lib/test/test_exceptions.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index c6fb848b8d7..c91f6662948 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 = (