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); > > > Can it be, that something is missing here? Imagine I allocate an > > object of a type: > > > t = MyImage() > > ,;- syntax_error 129=)/% #is a syntax error > > > How you see I would get a syntaxerror, but an object of the type > > MyImage() is created. But its deallocated when Py_Finalize() is > > called. What can I do to deallocate this object after > > PyObject_CallMethod returns NULL, too? I debug it, so if rvalue!=NULL > > the object is deallocated, but what can I do if rvalue==NULL= > > A syntax error is detected *before* the code runs -- so the object isn't > created at all. > > -- > Gabriel Genellina
Hi! 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? Thanks! -- http://mail.python.org/mailman/listinfo/python-list