mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
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:
committed by
intellij-monorepo-bot
parent
7d2018c336
commit
d50b3ad7ea
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
5
python/testData/highlighting/continueInFinallyBlock.py
Normal file
5
python/testData/highlighting/continueInFinallyBlock.py
Normal file
@@ -0,0 +1,5 @@
|
||||
while True:
|
||||
try:
|
||||
print("a")
|
||||
finally:
|
||||
continue
|
||||
@@ -0,0 +1,5 @@
|
||||
while True:
|
||||
try:
|
||||
print("a")
|
||||
finally:
|
||||
<error descr="'continue' not supported inside 'finally' clause">continue</error>
|
||||
@@ -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:
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user