[issue42522] [C API] Add Py_Borrow() function: call Py_XDECREF() and return the object

Ronald Oussoren report at bugs.python.org
Tue Dec 1 07:01:36 EST 2020


Ronald Oussoren <ronaldoussoren at mac.com> added the comment:

I'm -1 on adding this API as it is inherently unsafe and is bound to be used in locations where its contract is not honoured (especially outside of the core). 

Note that the pre-condition on the argument is that you now only own a reference to the object, but that there's also someone else that owns a reference.

It is better to bite the bullet and go for correct reference count updates when converting to the new PyFrame_GetCode API.

----------
nosy: +ronaldoussoren

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42522>
_______________________________________


More information about the Python-bugs-list mailing list