En Mon, 26 Jan 2009 08:47:31 -0200, <googler.1.webmas...@spamgourmet.com> escribió:
On 26 Jan., 03:25, "Gabriel Genellina" <gagsl-...@yahoo.com.ar> wrote:
En Sun, 25 Jan 2009 23:46:01 -0200, <googler.1.webmas...@spamgourmet.com> escribió:

> I have a problm with deallocating stuff. I call a function with this
> command:

> PyObject *rvalue = PyObject_CallMethod(obj, "execute","",NULL);

> if(rvalue==NULL)
>     PyErr_Print();
> else
>     Py_DECREF(rvalue);

Yes, you are right. I got this issue not in syntax error, I get it on
a runtime error like this:

t = MyImage()
self.test("hallo")   #test takes an integer so this would throw an
exception.

Here you see, an object of the type MyImage() was created but its not
deleted. 't' is a local reference so how can I do that?

It will be deleted after the last reference to it is released, as every object in Python. If the above two lines are the whole function code, this will happen when exiting the function. If some other object holds a reference to this MyImage instance (by example, by doing xxx.attribute = t, or inserting it in a list) then that won't happen until all those references are released. Note that, in Python 2.x, the traceback object holds a reference to all local variables -- if you store the traceback somewhere, those objects won't be deleted.

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to