Python C API (PyObject_CallMethod clear object)

googler.1.webmaster at spamgourmet.com googler.1.webmaster at spamgourmet.com
Mon Jan 26 02:46:01 CET 2009


Hi!

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=


Thanks a lot!!!!



More information about the Python-list mailing list