type 'slice' is not an acceptable base type

Michael Hoffman cam.ac.uk at mh391.invalid
Tue Dec 20 22:47:16 EST 2005


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.
-- 
Michael Hoffman



More information about the Python-list mailing list