type 'slice' is not an acceptable base type

Antoon Pardon apardon at forel.vub.ac.be
Wed Dec 21 04:36:21 EST 2005


Op 2005-12-21, Michael Hoffman schreef <cam.ac.uk at mh391.invalid>:
> Antoon Pardon wrote:
>
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in ?
>>   File "vslice.py", line 48, in ?
>>     class iterslice(slice):
>> TypeError: Error when calling the metaclass bases
>>     type 'slice' is not an acceptable base type
>
> Searching for "not an acceptable base type" in the Python source reveals 
> that this exception is produced when the proposed base type doesn't have 
> Py_TPFLAGS_BASETYPE set.
>
>> So what is going on. I thought the class vs type
>> distinction was eliminated in order to be able
>> to subclass base types. So why doesn't this work?
>
> slice.__base__ == object. It's the basetype flag issue. You could 
> propose a patch to make it subclassable.

I'll keep this is mind. It'll have to wait for after the holidays
though.

-- 
Antoon Pardon



More information about the Python-list mailing list