[3.11] gh-99153: set location on SyntaxError for try with both except and except* (GH-99160) (#99168)

This commit is contained in:
Irit Katriel 2022-11-07 09:41:20 +00:00 committed by GitHub
parent 263e9830aa
commit d8a42bcaf0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 5 deletions

View file

@ -1985,6 +1985,16 @@ class SyntaxTestCase(unittest.TestCase):
"Generator expression must be parenthesized",
lineno=1, end_lineno=1, offset=11, end_offset=53)
def test_except_then_except_star(self):
self._check_error("try: pass\nexcept ValueError: pass\nexcept* TypeError: pass",
r"cannot have both 'except' and 'except\*' on the same 'try'",
lineno=1, end_lineno=1, offset=1, end_offset=4)
def test_except_star_then_except(self):
self._check_error("try: pass\nexcept* ValueError: pass\nexcept TypeError: pass",
r"cannot have both 'except' and 'except\*' on the same 'try'",
lineno=1, end_lineno=1, offset=1, end_offset=4)
def test_empty_line_after_linecont(self):
# See issue-40847
s = r"""\