This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dsdale24
Recipients Darren.Dale, benjamin.peterson, daniel.urban, dsdale24, eric.araujo, ncoghlan, stutzbach
Date 2011-06-11.12:09:02
SpamBayes Score 7.9388274e-11
Marked as misclassified No
Message-id <BANLkTikKGepSW0haUy-aYiLGft5L1MM31Q@mail.gmail.com>
In-reply-to <BANLkTikwiSxLdCY83yn7hM46Jjr-Tu3zJg@mail.gmail.com>
Content
[...]
>> 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?
History
Date User Action Args
2011-06-11 12:09:03dsdale24setrecipients: + dsdale24, ncoghlan, benjamin.peterson, stutzbach, eric.araujo, daniel.urban, Darren.Dale
2011-06-11 12:09:02dsdale24linkissue11610 messages
2011-06-11 12:09:02dsdale24create