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 daniel.urban
Recipients daniel.urban, della, terry.reedy
Date 2010-08-13.15:57:46
SpamBayes Score 3.5127575e-06
Marked as misclassified No
Message-id <1281715068.86.0.782835998014.issue5867@psf.upfronthosting.co.za>
In-reply-to
Content
@abstractmethod
@classmethod
def ...
doesn't work because classmethod objects doesn't have a __dict__, so setting arbitrary attributes don't work, and abstractmethod tries to set the __isabstractmethod__ atribute to True.


The other order:
@classmethod
@abstractmethod
def ...
doesn't work, because the abstractmethod decorator sets the function's __isabstractmethod__ attribute to True, but when ABCMeta.__new__ checks the object in the namespace of the class, it won't find it, because the classmethod object won't have an __isabstractmethod__ attribute.

The situation is the same with staticmethod.

One possible solution would be adding a descriptor to classmethod (and staticmethod), with the name "__isabstractmethod__", which on __get__ would check its underlying callable for this attribute, and on __set__ would set this attribute on that callable. I think this way both order should work.
History
Date User Action Args
2010-08-13 15:57:49daniel.urbansetrecipients: + daniel.urban, terry.reedy, della
2010-08-13 15:57:48daniel.urbansetmessageid: <1281715068.86.0.782835998014.issue5867@psf.upfronthosting.co.za>
2010-08-13 15:57:47daniel.urbanlinkissue5867 messages
2010-08-13 15:57:47daniel.urbancreate