From 7b150630f02dd58eab7e1aa299cd31c510ad2423 Mon Sep 17 00:00:00 2001 From: David Halter Date: Sat, 12 Jan 2013 12:15:32 +0100 Subject: [PATCH] stopiteration works in strange ways in the parser in py2, fixes #70, affects probably davidhalter/jedi-vim#68 --- jedi/parsing.py | 4 +++- test/regression.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/jedi/parsing.py b/jedi/parsing.py index c7de5980..c80fb8f8 100644 --- a/jedi/parsing.py +++ b/jedi/parsing.py @@ -1276,7 +1276,9 @@ class PyFuzzyParser(object): self.top_module = top_module or self.module try: self._parse() - except common.MultiLevelStopIteration: + except (common.MultiLevelStopIteration, StopIteration): + # StopIteration needs to be added as well, because python 2 has a + # strange way of handling StopIterations. # sometimes StopIteration isn't catched. Just ignore it. pass diff --git a/test/regression.py b/test/regression.py index 9c16581d..ff3c5b7d 100755 --- a/test/regression.py +++ b/test/regression.py @@ -207,7 +207,7 @@ class TestRegression(TestBase): assert check(self.get_in_function_call(s, (4, 31)), 'compile', 0) # jedi-vim #70 s = """def foo(""" - assert check(self.get_in_function_call(s), None, 0) + assert self.get_in_function_call(s) is None def test_add_dynamic_mods(self): api.settings.additional_dynamic_modules = ['dynamic.py']