]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-111609: Test `end_offset` in SyntaxError subclass (GH-127830) (#130407)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 21 Feb 2025 14:56:39 +0000 (15:56 +0100)
committerGitHub <noreply@github.com>
Fri, 21 Feb 2025 14:56:39 +0000 (16:56 +0200)
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
Lib/test/test_exceptions.py

index c6fb848b8d7fdac234faa98f2376e2ee93e67ba2..c91f66629483e569da41c62fd0108b083d4d6a91 100644 (file)
@@ -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 = (