472,099 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,099 software developers and data experts.

__dict__ in class inherited from C extension module

Dear Python experts,

I have a strange problem - or more precisely, I'm not even sure if it's
a problem or not. I'm developing a Python extension module in C which
creates a new type with methods, mapping support and stuff like that :)
Everything's working fine, but if I inherit a new class from this type
in Python, I start getting strange warning messages in valgrind. Just a
simple example:

import mymodule

class InheritedType(mymodule.MyType):
def a_new_method(self): print "test"


("mymodule" is the C extension module I developed)
The error message I see in valgrind is the following:

==6579== Conditional jump or move depends on uninitialized value(s)
==6579== at 0x807CFF9: PyObject_GenericGetAttr (object.c:1283)
==6579== by 0x80B2EA3: PyEval_EvalFrame (ceval.c:1957)

I'm using Python 2.4.3, and by taking a look at the source of object.c
(line 1283), it looks like the tp_dict member of the type object of my
subclass is not initialized. The code snippet from line 1281-1285 looks
like this:

dictptr = (PyObject **) ((char *)obj + dictoffset);
dict = *dictptr;
if (dict != NULL) {
res = PyDict_GetItem(dict, name);
if (res != NULL) {

Should I worry about Valgrind's warning or is it just a false alarm? It
does not occur if I try to inherit my class from a built-in class (like
string or module or whatever), only if I use my extension's class, so I
suspect that I'm doing something wrong. Is there anything I should
watch out for when I create inheritable classes in a C extension?

Thanks a lot in advance.

Tamas <nt****@gmail.com>

May 9 '06 #1
0 915

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Ed Young | last post: by
5 posts views Thread by Jean Brouwers | last post: by
8 posts views Thread by Torsten Mohr | last post: by
8 posts views Thread by Steven Bethard | last post: by
2 posts views Thread by Dan Shookowsky | last post: by
8 posts views Thread by Steven D'Aprano | last post: by
7 posts views Thread by Georg Brandl | last post: by
13 posts views Thread by André | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.