C API for new-style classes
Eric Wilhelm
ewilhelm at somethinglike.sbcglobalDOTnet
Sat Jun 5 10:16:40 EDT 2004
Hi,
By new-style classes, I'm referring to the changes which came into 2.2 as
a result of PEP 252 and 253. I discovered this problem when trying to
use the Perl Inline::Python module with a python class that was
inheriting from the new builting 'object' class like so:
class MyClass(object):
The problem is in detecting that this class should be treated as a class
from C. With old-style classes, PyClass_Check() returns true, but it
doesn't work with new-style classes. With those, apparently we have to
use PyType_Check(), but I cannot find this in the extension
documentation.
Another problem comes in identifying instances of this type of
type-class, where PyInstance_Check() no longer returns true.
Does anyone know of any documentation for the API for new-style classes?
(It must work somehow or the python interpreter couldn't do it.)
Thanks,
Eric
More information about the Python-list
mailing list