mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-06 12:54:29 +08:00
Support finally in continue on 3.8+
Thanks to [bpo-32489](https://bugs.python.org/issue32489) and sadly
for rejection of my [PEP 601](https://www.python.org/dev/peps/pep-0601/)
finally in continue is supported in 3.8+. I checked the blame and looks
like there was already a commit for the same subject, but that only
changes the test and not actually changes the checker (dfe7fba08e)
This commit is contained in:
@@ -449,7 +449,11 @@ class _ContinueChecks(SyntaxRule):
|
||||
in_loop = True
|
||||
if block.type == 'try_stmt':
|
||||
last_block = block.children[-3]
|
||||
if last_block == 'finally' and leaf.start_pos > last_block.start_pos:
|
||||
if (
|
||||
last_block == "finally"
|
||||
and leaf.start_pos > last_block.start_pos
|
||||
and self._normalizer.version < (3, 8)
|
||||
):
|
||||
self.add_issue(leaf, message=self.message_in_finally)
|
||||
return False # Error already added
|
||||
if not in_loop:
|
||||
|
||||
@@ -7,6 +7,8 @@ import warnings
|
||||
import pytest
|
||||
|
||||
import parso
|
||||
|
||||
from textwrap import dedent
|
||||
from parso._compatibility import is_pypy
|
||||
from .failing_examples import FAILING_EXAMPLES, indent, build_nested
|
||||
|
||||
@@ -324,3 +326,16 @@ def test_invalid_fstrings(code, message):
|
||||
def test_trailing_comma(code):
|
||||
errors = _get_error_list(code)
|
||||
assert not errors
|
||||
|
||||
def test_continue_in_finally():
|
||||
code = dedent('''\
|
||||
for a in [1]:
|
||||
try:
|
||||
pass
|
||||
finally:
|
||||
continue
|
||||
''')
|
||||
assert not _get_error_list(code, version="3.8")
|
||||
assert _get_error_list(code, version="3.7")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user