Python C API: How to debug reference leak?

Chris Angelico rosuav at gmail.com
Wed Sep 28 07:34:52 EDT 2016


On Wed, Sep 28, 2016 at 9:25 PM, Gregory Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> Chris Angelico wrote:
>>
>> If you've Py_DECREFed it and then peek into its internals, you're
>> aiming a gun at your foot.
>
>
> That's true. A safer way would be to look at the refcount
> *before* decreffing and verify that it's what you expect.

Exactly, which is presumably what dieter meant by a refcount of 1
being the one you're holding. A refcount of *2* indicates another
reference somewhere.

ChrisA



More information about the Python-list mailing list