Sublassing in C
Greg Chapman
glc at well.com
Sun Aug 15 09:46:56 EDT 2004
On Sat, 14 Aug 2004 15:31:26 +0200, Dennis Kaarsemaker
<spamtrap at kaarsemaker.net> wrote:
>I'm trying to create a subclass of Exception in C, but cant figure out
>what to use as tp_base in the PyTypeObject struct. Can anybody give me
>directions on where to look or maybe even an answer?
Currently, exceptions have to be old-style classes, so you cannot create a
subclass using the new type-based subclassing. Instead, you should use
PyErr_NewException, which creates a new Exception subclass with the given name,
base and attributes (despite the first sentence of the documentation, it returns
a new subclass, not a new exception object).
---
Greg Chapman
More information about the Python-list
mailing list