File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222
2323.. moduleauthor:: Stefan Zimmermann <zimmermann.code@gmail.com>
2424"""
25+ from itertools import chain
26+
2527from moretools import cached , qualname , dictitems
2628
2729from .base import metabase as base
@@ -160,8 +162,14 @@ def __abstractmethods__(cls):
160162 def abcnames ():
161163 """Generator.
162164 """
163- for name in dir (cls ):
165+ # don't just iterate dir(cls) as it might contain dynamic members,
166+ # which maybe involve cls instantiation on getattr(),
167+ # which leads to endless recursion.
168+ # and anyway: abstractmethods should always be explicitly defined!
169+ for name in set (chain (dir (type (cls )),
170+ * (c .__dict__ for c in cls .mro ())):
164171 if name == '__abstractmethods__' :
172+ # another way to avoid recursion :)
165173 continue
166174 obj = getattr (cls , name , None )
167175 if obj is None :
You can’t perform that action at this time.
0 commit comments