Skip to content

Commit

Permalink
Check ^ location
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Aug 29, 2024
1 parent 29f93da commit 7b094c3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Lib/test/test_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -2800,6 +2800,23 @@ def test_deep_invalid_rule(self):
with self.assertRaises(SyntaxError):
compile(source, "<string>", "exec")

def test_except_stmt_invalid_as_expr(self):
self._check_error(
textwrap.dedent(
"""
try:
pass
except ValueError as obj.attr:
pass
"""
),
errtext="cannot use except statement with attribute",
lineno=4,
end_lineno=4,
offset=22,
end_offset=22 + len("obj.attr"),
)


def load_tests(loader, tests, pattern):
tests.addTest(doctest.DocTestSuite())
Expand Down

0 comments on commit 7b094c3

Please sign in to comment.