diff --git a/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java b/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java index d1bce00df3ec..663f795a4429 100644 --- a/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java +++ b/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java @@ -52,6 +52,10 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor { public void visitPyClass(final PyClass node) { // Create node and stop here myBuilder.startNode(node); + final ReadWriteInstruction instruction = ReadWriteInstruction.newInstruction(myBuilder, node, node.getName(), + ReadWriteInstruction.ACCESS.WRITE); + myBuilder.addNode(instruction); + myBuilder.checkPending(instruction); } @Override @@ -64,7 +68,8 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor { public void visitPyCallExpression(final PyCallExpression node) { final PyExpression callee = node.getCallee(); // Flow abrupted - if (callee != null && "sys.exit".equals(PyUtil.getReadableRepr(callee, true))) { + if (callee != null && ("sys.exit".equals(PyUtil.getReadableRepr(callee, true)) || + "fail".equals(callee.getName()))) { callee.accept(this); for (PyExpression expression : node.getArguments()) { expression.accept(this); diff --git a/python/src/com/jetbrains/python/psi/impl/PythonLanguageLevelPusher.java b/python/src/com/jetbrains/python/psi/impl/PythonLanguageLevelPusher.java index 8d8cb5b436b4..e66419056233 100644 --- a/python/src/com/jetbrains/python/psi/impl/PythonLanguageLevelPusher.java +++ b/python/src/com/jetbrains/python/psi/impl/PythonLanguageLevelPusher.java @@ -170,7 +170,7 @@ public class PythonLanguageLevelPusher implements FilePropertyPusher30 This code is unreachable - unreachable.py 36 This code is unreachable - unreachable.py 46 This code is unreachable + + unreachable.py + 69 + This code is unreachable + diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/importExceptImportError.py b/python/testData/inspections/PyUnresolvedReferencesInspection/importExceptImportError.py index c2cf55a09564..4edf12c6253a 100644 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/importExceptImportError.py +++ b/python/testData/inspections/PyUnresolvedReferencesInspection/importExceptImportError.py @@ -42,8 +42,18 @@ def f(): # PY-3869 def f(x): try: - from foo import bar + from foo import bar #pass except ImportError: def bar(x): return x - return bar(x) \ No newline at end of file + return bar(x) + +# PY-3919 +def f(x): + try: + from foo import Bar #pass + except ImportError: + class Bar(object): + pass + return Bar() +