Hello,

I'm trying to develop an extension module in C, but am having some
difficulties.  I thought about posting to the general python mailling
list, but since it has to do with the C API I figured this was the correct
location.

My difficulty lies with subclassing a class provided by another external
module.  I have access to the structure definition, so I can determine the
size fo the tp_basicsize member of the PyTypeObject structure.  What I
can't seem to determine is value for the tp_base element.

This is my current "best guess".

        PyObject* superclass;
        superclass = PyObject_GetAttrString( module, "SuperClass" );
        if ( !superclass ) return;
        type.tp_base = superclass->ob_type;
        Py_DECREF( superclass );

        type.tp_new = PyType_GenericNew;
        if ( PyType_Ready( &type ) < 0 ) return;

Unfortunately, I seem to be inheriting from the type object for
SuperClass, and not from SuperClass itself.

I would greatly appreciate some direction on this issue.

Thank-you,

----------------------------------------
Robert Johnstone
Simon Fraser University
http://www.sfu.ca/~rjohnsto/

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to