Reference count nanny

The "refnanny" is a system used while testing Cython, to make sure that no refcount errors happen through the execution path the Cython testcases takes. It only tests the correct operation of Cython itself, not user code.

The basics

__Pyx_GIVEREF(obj)
PyList_SET_ITEM(..., obj, ...)

and

obj = Py_Get...
if (!obj) { ... }
__Pyx_GOTREF(obj)

(Also, XGIVEREF is called on __pyx_r prior to returning.)

One can get reference count errors (which are printed to output and/or logged in a module variable, see refnanny.pyx) for two reasons:

Running with the nanny

Default in runtests.py, can be turned off by --no-refnanny.

If you want to run it on your own project, assuming you have a standard install of Cython (with the refnanny module in Cython.Runtime.refnanny), simply compile with -DCYTHON_REFNANNY.

enhancements/refnanny (last edited 2009-03-31 13:02:22 by DagSverreSeljebotn)