This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients
Date 2004-09-27.09:46:20
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=1038590

Without seeing the original code, I'm not convinced this is
a Python problem. This is due to the fact that inheriting
from builtin's and standard library objects defined in C
works fine.

For instance, inheriting dict's __len__ is shown here:
>>> class foo(dict): pass
...
>>> len(foo())
0
>>> foo.__len__
<slot wrapper '__len__' of 'dict' objects>

But grep shows the dict source makes no reference to
'__len__'  directly:
[...@localhost src]$ grep -Hc "__len__" Objects/dictobject.c
Objects/dictobject.c:0

The way it works is that PyType_Ready generates the
appropriate __dict__ entries for all of the special methods
that are defined at the C level (i.e. have non-null pointers).

If you aren't invoking PyType_Ready before using your class,
then it won't work properly. (This invocation is usually
made in the C module's initialisation method). See the
"Extending and Embedding" docs for all the gory details.
History
Date User Action Args
2007-08-23 14:26:26adminlinkissue1034178 messages
2007-08-23 14:26:26admincreate