reference count

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • J

    #1

    reference count

    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_SetItemS tring(lDict, "item", (PyObject*)iIte m->mPyObject);
    PyObject* lResult = PyEval_EvalCode (mCode, ScnGlobal::sDic tionary,
    lDict);
    if (! lResult)
    {
    PyErr_Print();
    }
    else
    {
    Py_DECREF(lResu lt);
    }
    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

    #2
    Re: reference count

    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

    Comment

    Working...