1
0
forked from VimPlug/jedi

implemented __next__ method

This commit is contained in:
David Halter
2012-08-08 15:56:43 +02:00
parent a0fad34503
commit 024cc78b2c
2 changed files with 36 additions and 2 deletions

View File

@@ -17,7 +17,7 @@ TODO nonlocal statement
TODO __ instance attributes should not be visible outside of the class.
TODO getattr / __getattr__ / __getattribute__ ?
"""
from _compatibility import next, property, hasattr
from _compatibility import next, property, hasattr, is_py3k
import sys
import itertools
@@ -939,7 +939,7 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
try:
generators += it.execute_subscope_by_name('__iter__')
except KeyError:
pass
debug.warning('`for r in x`: x has no __iter__ method')
result = []
for gen in generators:
@@ -948,6 +948,13 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
# array, but there's also the list builtin, which is
# another thing.
in_vars = gen.get_index_types()
elif isinstance(gen, Instance):
# __iter__ returned an instance.
name = '__next__' if is_py3k() else 'next'
try:
in_vars = it.execute_subscope_by_name(name)
except KeyError:
debug.warning('Instance has no __next__ function', gen)
else:
# is a generator
in_vars = gen.get_content()