diff --git a/jedi/evaluate/compiled/__init__.py b/jedi/evaluate/compiled/__init__.py index 1b11bbce..2bb5c10d 100644 --- a/jedi/evaluate/compiled/__init__.py +++ b/jedi/evaluate/compiled/__init__.py @@ -207,6 +207,9 @@ class CompiledObject(Context): return for i, part in enumerate(self.obj): + if i > 20: + # Should not go crazy with large iterators + break yield LazyKnownContext(create(self.evaluator, part)) def py__name__(self): diff --git a/test/test_api/test_interpreter.py b/test/test_api/test_interpreter.py index 6b170ad4..8d25d4be 100644 --- a/test/test_api/test_interpreter.py +++ b/test/test_api/test_interpreter.py @@ -218,3 +218,10 @@ def test_param_completion(): _assert_interpreter_complete('foo(bar', locals(), ['bar']) # TODO we're not yet using the Python3.5 inspect.signature, yet. assert not jedi.Interpreter('lambd(xyz', [locals()]).completions() + + +def test_endless_yield(): + lst = [1] * 10000 + # If iterating over lists it should not be possible to take an extremely + # long time. + _assert_interpreter_complete('list(lst)[9000].rea', locals(), ['real'])