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

You are not wrong. On the other hand, I often depend on the fact that an empty list or dictionary is false, and true if not empty. It is quite convenient, and I find it reasonably logical.
On Mon, Dec 17, 2012 at 1:59 PM, Campbell Barton <ideasman42@gmail.com>wrote:
Take care using PyObject_IsTrue since it will accept many PyObject's (floats, lists, dicts etc), if you want to be strict with checking your input its not always so good. Instead you can use PyLong_AsLong() this works for True/False and any int type.
eg: int param = PyLong_AsLong(value); if (param == -1 && PyErr_Occurred()) { .... error out ... } ... check the int now ...
On Mon, Dec 17, 2012 at 10:23 PM, Gustavo Carneiro <gjcarneiro@gmail.com> wrote:
PyObject_IsTrue(
--
- Campbell
capi-sig mailing list capi-sig@python.org http://mail.python.org/mailman/listinfo/capi-sig
-- Gustavo J. A. M. Carneiro "The universe is always one step beyond logic." -- Frank Herbert
participants (1)
-
Gustavo Carneiro