davidmalcolm / gcc-python-plugin

GCC plugin that embeds CPython inside the compiler
GNU General Public License v3.0
199 stars 58 forks source link

False refleak warning with PyObject_CallMethod and "N" argument specificier #95

Open davidmalcolm opened 7 years ago

davidmalcolm commented 7 years ago

CPyChecker warns that "ob_refcnt of PyBool_FromLong is 1 too high" in code like this:

PyObject_CallMethod(obj, "methodname", "N", PyBool_FromLong(0));

In fact, the "N" specifier means that PyObject_CallMethod steals the reference if the return value of PyBool_FromLong is non-NULL.

davidmalcolm commented 7 years ago

Imported from trac issue 55. Created by emptysquare on 2014-01-29T15:58:04, last modified: 2014-01-29T15:58:04