diff --git a/python/src/com/jetbrains/python/psi/resolve/PyResolveUtil.java b/python/src/com/jetbrains/python/psi/resolve/PyResolveUtil.java index f943255c81db..1c9d5728462a 100644 --- a/python/src/com/jetbrains/python/psi/resolve/PyResolveUtil.java +++ b/python/src/com/jetbrains/python/psi/resolve/PyResolveUtil.java @@ -101,6 +101,7 @@ public class PyResolveUtil { @Nullable public static PsiElement getPrevNodeOf(PsiElement elt, PsiScopeProcessor proc) { + if (elt instanceof PsiFile) return null; // no sense to get the previous node of a file if (proc instanceof PyClassScopeProcessor) { return getPrevNodeOf(elt, ((PyClassScopeProcessor)proc).getPossibleTargets()); } diff --git a/python/testData/resolve/multiFile/stackOverflowOnEmptyFile/StackOverflowOnEmptyFile.py b/python/testData/resolve/multiFile/stackOverflowOnEmptyFile/StackOverflowOnEmptyFile.py new file mode 100644 index 000000000000..edf61fa3f0bb --- /dev/null +++ b/python/testData/resolve/multiFile/stackOverflowOnEmptyFile/StackOverflowOnEmptyFile.py @@ -0,0 +1,4 @@ +from tornado.options import define + +define() +# diff --git a/python/testData/resolve/multiFile/stackOverflowOnEmptyFile/tornado/options.py b/python/testData/resolve/multiFile/stackOverflowOnEmptyFile/tornado/options.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/testSrc/com/jetbrains/python/PyMultiFileResolveTest.java b/python/testSrc/com/jetbrains/python/PyMultiFileResolveTest.java index 6d81ad89be44..9b8f4c709c90 100644 --- a/python/testSrc/com/jetbrains/python/PyMultiFileResolveTest.java +++ b/python/testSrc/com/jetbrains/python/PyMultiFileResolveTest.java @@ -134,6 +134,10 @@ public class PyMultiFileResolveTest extends PyLightFixtureTestCase { assertEquals("Context", ((PyClass) element).getName()); } + public void testStackOverflowOnEmptyFile() throws Exception { + assertNull(doResolve()); // make sure we don't have a SOE here + } + private PsiFile prepareFile() throws Exception { String testName = getTestName(true); String fileName = getTestName(false) + ".py";