type 'slice' is not an acceptable base type

A

Antoon Pardon

That was the message I received when I imported a self
written module. All I wanted to do was experiment with
subclassing slice. So I write something like:

class iterslice(slice):
...


And when I fired up the python interpreter
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


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?
 
M

Michael Hoffman

Antoon said:
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.
 
A

Antoon Pardon

Op 2005-12-21 said:
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.


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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top