How to find who is decref'ing Py_None on me!

Just van Rossum just at letterror.com
Wed Aug 9 11:27:59 EDT 2000


Warren Postma wrote:
> 
> (It's got to be Me, of course, but where in the C sources...)
> 
> I have an embedded/extended Python App in which the reference counts on
> Py_None are creeping towards zero during program run, and I'd like to find
> which DECREFs are causing it. Anybody done this and can tell me a good
> debugging technique? there are literally thousands of these in the Python
> 1.5 sources, plus a few hundred in my own code.  Typically, I guess, it's
> being decref'd because it's being returned as the result of a function, but
> whoever is returning it is not incref'ing it first.  So that gets tricky to
> find.  Ow.

You could try to search for instances of

	return Py_None;

that are not preceded by

	Py_INCREF(Py_None);

..but that would obviously also not catch everything.

Just



More information about the Python-list mailing list