Issue #10565: Iterator ABC should require both __next__ and __iter__.

This commit is contained in:
Raymond Hettinger 2010-11-29 03:56:12 +00:00
parent 263cbdfdfb
commit ead22227cc
3 changed files with 13 additions and 3 deletions

View file

@ -90,7 +90,8 @@ class Iterator(Iterable):
@classmethod
def __subclasshook__(cls, C):
if cls is Iterator:
if any("__next__" in B.__dict__ for B in C.__mro__):
if (any("__next__" in B.__dict__ for B in C.__mro__) and
any("__iter__" in B.__dict__ for B in C.__mro__)):
return True
return NotImplemented