PyObject_SetAttrString - doesn't set instance attribute

Jason jason.heeris at gmail.com
Sun May 2 06:26:46 EDT 2010


On May 2, 5:52 pm, Carl Banks <pavlovevide... at gmail.com> wrote:
> Not sure what you're doing here.  It looks like you are being passed
> an object of a given type, then you get the type object, call it to
> create another object of that type, and assign it to object->instance.

Sorry, I should have noted that the "NautilusPythonObject" type in the
code is a struct defined as:

struct _NautilusPythonObject {
  GObject parent_slot;
  PyObject *instance;
};

> You are assigning the attirbute the the object that the C code refers
> to as "object->instance", but it seems that in the Python snippet you
> are calling getattr on the object that the C code refers to as
> "object".

object->instance is the PyObject, and I gathered that it was the
correct thing to assign to from the fact that the address is identical
as seen from C and Python.

— Jason



More information about the Python-list mailing list