Skip to content

Commit

Permalink
get rid of side effects in the interpreter if trying to use the index…
Browse files Browse the repository at this point in the history
… on an iterable (using __getitem__)
  • Loading branch information
davidhalter committed Apr 7, 2014
1 parent 17345b6 commit 193e04a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion jedi/evaluate/compiled/__init__.py
Expand Up @@ -96,7 +96,12 @@ def get_subscope_by_name(self, name):
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:
Expand Down

0 comments on commit 193e04a

Please sign in to comment.