Don't mark continue in finally block as an error in Python 3.8+ (PY-36003)

Enable a test that no one is care of.

GitOrigin-RevId: ccc520d6ab6d40117b5ff69ffe908ef135c6a08b
This commit is contained in:
Semyon Proshev
2019-07-23 17:37:23 +03:00
committed by intellij-monorepo-bot
parent 7d2018c336
commit d50b3ad7ea
5 changed files with 23 additions and 13 deletions

View File

@@ -16,10 +16,7 @@
package com.jetbrains.python.validation;
import com.intellij.psi.util.PsiTreeUtil;
import com.jetbrains.python.psi.PyBreakStatement;
import com.jetbrains.python.psi.PyContinueStatement;
import com.jetbrains.python.psi.PyFinallyPart;
import com.jetbrains.python.psi.PyLoopStatement;
import com.jetbrains.python.psi.*;
import static com.jetbrains.python.PyBundle.message;
@@ -39,7 +36,8 @@ public class BreakContinueAnnotator extends PyAnnotator {
if (node.getLoopStatement() == null) {
getHolder().createErrorAnnotation(node, message("ANN.continue.outside.loop"));
}
else if (PsiTreeUtil.getParentOfType(node, PyFinallyPart.class, false, PyLoopStatement.class) != null) {
else if (LanguageLevel.forElement(node).isOlderThan(LanguageLevel.PYTHON38) &&
PsiTreeUtil.getParentOfType(node, PyFinallyPart.class, false, PyLoopStatement.class) != null) {
getHolder().createErrorAnnotation(node, message("ANN.cant.continue.in.finally"));
}
}

View File

@@ -0,0 +1,5 @@
while True:
try:
print("a")
finally:
continue

View File

@@ -0,0 +1,5 @@
while True:
try:
print("a")
finally:
<error descr="'continue' not supported inside 'finally' clause">continue</error>

View File

@@ -1,9 +1,3 @@
while True:
try:
print "a"
finally:
<error descr="'continue' not supported inside 'finally' clause">continue</error>
for x in [1, 2, 3]:
pass
else:

View File

@@ -80,6 +80,16 @@ public class PythonHighlightingTest extends PyTestCase {
doTest(false, false);
}
// PY-36003
public void testContinueInFinallyBlockBefore38() {
doTest(LanguageLevel.PYTHON37, false, false);
}
// PY-36003
public void testContinueInFinallyBlock() {
doTest(LanguageLevel.PYTHON38, false, false);
}
public void testReturnWithArgumentsInGenerator() {
doTest();
}
@@ -109,11 +119,9 @@ public class PythonHighlightingTest extends PyTestCase {
doTest(false, false);
}
/*
public void testStringEscapedOK() {
doTest();
}
*/
public void testStringMixedSeparatorsOK() { // PY-299
doTest();