Skip to content

Commit 1911c20

Browse files
isidenticalmyint
authored andcommitted
Allow continue inside finally in 3.8+ (#476)
1 parent ffe9386 commit 1911c20

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

pyflakes/checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1738,7 +1738,7 @@ def CONTINUE(self, node):
17381738
break
17391739
# Handle Try/TryFinally difference in Python < and >= 3.3
17401740
if hasattr(n, 'finalbody') and isinstance(node, ast.Continue):
1741-
if n_child in n.finalbody:
1741+
if n_child in n.finalbody and not PY38_PLUS:
17421742
self.report(messages.ContinueInFinally, node)
17431743
return
17441744
if isinstance(node, ast.Continue):

pyflakes/test/test_other.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,10 @@ def test_continueInsideLoop(self):
493493
continue
494494
''')
495495

496+
@skipIf(version_info > (3, 8), "Python <= 3.8 only")
496497
def test_continueInFinally(self):
497498
# 'continue' inside 'finally' is a special syntax error
499+
# that is removed in 3.8
498500
self.flakes('''
499501
while True:
500502
try:
@@ -2003,6 +2005,7 @@ async def read_data(db):
20032005
''', m.BreakOutsideLoop)
20042006

20052007
@skipIf(version_info < (3, 5), 'new in Python 3.5')
2008+
@skipIf(version_info > (3, 8), "Python <= 3.8 only")
20062009
def test_continueInAsyncForFinally(self):
20072010
self.flakes('''
20082011
async def read_data(db):

0 commit comments

Comments
 (0)