mirror of
https://github.com/python/cpython.git
synced 2025-08-09 03:19:15 +00:00
[3.12] gh-111609: end_offset
is ignored in subclasses of SyntaxError (#127554)
* `end_offset` is ignored in subclasses of SyntaxError * 📜🤖 Added by blurb_it. * Add test --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
This commit is contained in:
parent
20c0c8cf38
commit
487a51a1b9
3 changed files with 45 additions and 34 deletions
|
@ -2195,6 +2195,22 @@ 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 = (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue