[issue36880] Returning None from a callback with restype py_object decrements None's refcount too much
dgelessus
report at bugs.python.org
Mon May 13 06:17:21 EDT 2019
dgelessus <dgelessus+bugs.python.org at me.com> added the comment:
Thank you for looking into this! I can confirm that Eryk Sun's change fixes the issue for me locally.
I'm up for making the patch for this. Regarding tests, I see there are already some refcount-related ctypes tests in Lib/ctypes/test/test_refcounts.py - should I add another test case there that reproduces this situation and ensures that None's refcount is unaffected? (I imagine testing against None's refcount will be a bit fragile, so it might be best to call the previously-buggy function in a loop and check afterwards that None's refcount hasn't changed significantly.)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36880>
_______________________________________
More information about the Python-bugs-list
mailing list