From 193e04ae8edf67638a6fc61b55bf5cc9844f7c2b Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 7 Apr 2014 16:11:23 +0200 Subject: [PATCH] get rid of side effects in the interpreter if trying to use the index on an iterable (using __getitem__) --- jedi/evaluate/compiled/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jedi/evaluate/compiled/__init__.py b/jedi/evaluate/compiled/__init__.py index 61208a82..6c7efb2e 100644 --- a/jedi/evaluate/compiled/__init__.py +++ b/jedi/evaluate/compiled/__init__.py @@ -96,7 +96,12 @@ class CompiledObject(Base): def get_index_types(self, index_types): # If the object doesn't have `__getitem__`, just raise the # AttributeError. - self.obj.__getitem__ + if not hasattr(self.obj, '__getitem__'): + debug.warning('Tried to call __getitem__ on non-iterable.') + return [] + if type(self.obj) not in (str, list, tuple): + # Get rid of side effects, we won't call custom `__getitem__`s. + return [] result = [] for typ in index_types: