On Thu, Dec 13, 2012 at 4:21 PM, Robert Steckroth <robertsteckroth(a)gmail.com
> wrote:
> Does the below statement have a memory leak?
>
> if ( PyObject_Compare(update_var, Py_False)
>
> Do I need to assign the Py_False first and DECREF it, or is the above
> snippet ok alone.
>
It's safe, but note that it is more correct to use PyObject_IsTrue: there
are more values that can be considered true or false, besides python's True
and False objects.
if (!PyObject_IsTrue(update_var)) { ... }
--
Gustavo J. A. M. Carneiro
"The universe is always one step beyond logic." -- Frank Herbert