Author daniel.urban
Recipients daniel.urban, eric.araujo, roalddevries, terry.reedy
Date 2010-10-01.14:10:03
SpamBayes Score 1.68509e-07
Marked as misclassified No
Message-id <>
If we create a new class, which is a metaclass, and also inherits an ABC, we create a new instance of ABCMeta.

When ABCMeta.__new__ creates the __abstractmethods__ attribute of the new class, it iterates over the __abstractmethods__ attribute of every base class (and checks every name in it, if it's abstract in the new class). One of the base classes of a metaclass is of course type. The type.__abstractmethods__ object is a getset descriptor (its __set__ switches some flags in tp_flags), which isn't iterable, so it raises the exception. 

Ideas for possible solutions:
1. In ABCMeta.__new__ special case type (do not check its __abstractmethods__attribute). 
2. In ABCMeta.__new__ check if the __abstractmethods__ attribute is in fact an iterable, before we try to iterate over it. (I don't think this would be a very good solution, because if a base class' __abstractmethods__ isn't iterable, it should be an error, except if the base class is type itself. So we should special case type anyway.)

I can't come up with a use case for this right now, but I don't see why it shouldn't work.
Date User Action Args
2010-10-01 14:10:07daniel.urbansetrecipients: + daniel.urban, terry.reedy, eric.araujo, roalddevries
2010-10-01 14:10:06daniel.urbansetmessageid: <>
2010-10-01 14:10:04daniel.urbanlinkissue9533 messages
2010-10-01 14:10:03daniel.urbancreate