Skip to content

Commit cb8d89d

Browse files
[3.13] gh-111609: Test end_offset in SyntaxError subclass (GH-127830) (#130407)
Co-authored-by: Nice Zombies <[email protected]>
1 parent 8ce48c8 commit cb8d89d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Lib/test/test_exceptions.py

+15
Original file line numberDiff line numberDiff line change
@@ -2253,6 +2253,21 @@ def test_range_of_offsets(self):
22532253
self.assertIn(expected, err.getvalue())
22542254
the_exception = exc
22552255

2256+
def test_subclass(self):
2257+
class MySyntaxError(SyntaxError):
2258+
pass
2259+
2260+
try:
2261+
raise MySyntaxError("bad bad", ("bad.py", 1, 2, "abcdefg", 1, 7))
2262+
except SyntaxError as exc:
2263+
with support.captured_stderr() as err:
2264+
sys.__excepthook__(*sys.exc_info())
2265+
self.assertIn("""
2266+
File "bad.py", line 1
2267+
abcdefg
2268+
^^^^^
2269+
""", err.getvalue())
2270+
22562271
def test_encodings(self):
22572272
self.addCleanup(unlink, TESTFN)
22582273
source = (

0 commit comments

Comments
 (0)