reference count

J

J

Hi,


I have a problem with the reference count after an error occurs
in a script which I execute as follows..

PyObject* lDict = PyDict_New();
PyDict_SetItemString(lDict, "item", (PyObject*)iItem->mPyObject);
PyObject* lResult = PyEval_EvalCode(mCode, ScnGlobal::sDictionary,
lDict);
if (! lResult)
{
PyErr_Print();
}
else
{
Py_DECREF(lResult);
}
Py_DECREF(lDict);


The script within the mCode object only contains the following line,
which generates an error.

print aasas


The problem is that after PyEval_EvalCode returns the reference count
for lDict is one larger than before. Py_DECREF(lDict) does
therefore not delete the Dictionary, which causes me problems. Is
Python keeping an exception around. I assume that I have to do some
more cleanup ??


Cheers
Jochen
 
J

J

I tend to answer my own questions a lot. But he, lets grow the
knowledge base :)... PyErr_Clear() after PyErr_Print did the trick....

J
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top