https://github.com/python/cpython/commit/e8f4e272cc828f2b79fa17fc6b9786bdddab7ce4
commit: e8f4e272cc828f2b79fa17fc6b9786bdddab7ce4
branch: main
author: Nice Zombies <[email protected]>
committer: pablogsal <[email protected]>
date: 2024-12-11T19:32:54+01:00
summary:
gh-111609: Test `end_offset` in SyntaxError subclass (#127830)
Test `end_offset` in SyntaxError subclass
files:
M Lib/test/test_exceptions.py
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 5beeac3adfc065..6ccfa9575f8569 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -2274,6 +2274,21 @@ def test_range_of_offsets(self):
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 = (
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]