Darren Dale <dsdal...@gmail.com> added the comment: [...] >> Traceback (most recent call last): >> File "<stdin>", line 1, in <module> >> TypeError: Can't instantiate abstract class D with abstract methods >> foo.__func__ > > You still need to use @abc.abstractstaticmethod.
Thinking about this some more, I think the error you found should be considered a problem. The issue is with the descriptor access itself: In class C we inspect the staticmethod instance in the namespace dict passed to ABCMeta and find foo's abstract __func__. But later, ABCMeta identifies C as a base of D, identifies C.foo.__func__ from C.__abstractmethods__, then does a getattr on the formative D class. D.__dict__['foo'] is a descriptor, which when accessed as D.foo returns D.__dict__['foo'].__func__ (as opposed to the other descriptors we have been discussing, where descriptor "get" access is only invoked by an instance of the class). ABCMeta needs to inspect the descriptor itself, not whatever the descriptor wants to return when accessed. We can't use D.__dict__ to access the foo descriptor, since some other base class of D may have provided the concrete implementation of foo. Does anyone know another way to search the MRO and return the foo descriptor? You helped bring up another point: all functions are descriptors, since they all have __get__ methods. That means every method is going to be inspected for abstract members. Is this a problem? ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11610> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com