mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-17 05:49:37 +08:00
Fix: In the py__iter__ version, we didn't respect __next__ being an option.
This commit is contained in:
@@ -34,7 +34,7 @@ import imp
|
|||||||
import re
|
import re
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
|
||||||
from jedi._compatibility import use_metaclass, unicode, Python3Method
|
from jedi._compatibility import use_metaclass, unicode, Python3Method, is_py3
|
||||||
from jedi.parser import tree
|
from jedi.parser import tree
|
||||||
from jedi import debug
|
from jedi import debug
|
||||||
from jedi import common
|
from jedi import common
|
||||||
@@ -218,9 +218,18 @@ class Instance(use_metaclass(CachedMetaClass, Executed)):
|
|||||||
debug.warning('No __iter__ on %s.' % self)
|
debug.warning('No __iter__ on %s.' % self)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
for generator in self._evaluator.execute(method):
|
iters = self._evaluator.execute(method)
|
||||||
for typ in generator.py__iter__():
|
for generator in iters:
|
||||||
yield typ
|
if isinstance(generator, Instance):
|
||||||
|
# `__next__` logic.
|
||||||
|
name = '__next__' if is_py3 else 'next'
|
||||||
|
try:
|
||||||
|
yield generator.execute_subscope_by_name(name)
|
||||||
|
except KeyError:
|
||||||
|
debug.warning('Instance has no __next__ function in %s.', generator)
|
||||||
|
else:
|
||||||
|
for typ in generator.py__iter__():
|
||||||
|
yield typ
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@underscore_memoization
|
@underscore_memoization
|
||||||
|
|||||||
Reference in New Issue
Block a user