Re: [capi-sig] Does Py_False or Py_True need de-referencing if used in a PyObject_Compare?

Dec. 17, 2012
9:23 a.m.
On Thu, Dec 13, 2012 at 4:21 PM, Robert Steckroth <robertsteckroth@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
4532
Age (days ago)
4532
Last active (days ago)
0 comments
1 participants
participants (1)
-
Gustavo Carneiro