On 15.06.2020 11:35, Petr Viktorin wrote:
On 2020-06-15 11:14, M.-A. Lemburg wrote:
On 15.06.2020 11:02, Petr Viktorin wrote:
On 2020-06-14 22:10, cpython@nicwatson.org wrote:
I maintain an open source Python module in C. I'm trying to verify for the first time that the module still works with cpython 3.9. This module does *not* use the "limited" C API.
In building my module against 3.9b3, I'm getting a missing declaration warning on _Py_ForgetReference. My module builds and passes test fine, this is just a compiler warning issue.
What does the _Py_ForgetReference function do? The documentation says it's only for use in the interpereter core, so I'd assume it's .
This is typically used in error handlers of constructors where you want to avoid having the deallocator run as result of the DECREF, e.g. because the object has not been full initialized yet.
For that I'd recommend marking the object invalid (e.g. by setting some vital pointer in it to NULL), and teaching the deallocator to skip its logic.
If that's not enough we could document and support a "Py_ForgetReference" as public API in CPython. But having only internal API for a use case is not good.
Sure, there are often workarounds which can be used, but we do need some way to tell the interpreter "the initialization had a problem, please remove the object from your internal management resources without calling the deallocator".
Perhaps a new public API could be created for this purpose, like you say.
-- Marc-Andre Lemburg eGenix.com
Professional Python Services directly from the Experts (#1, Jun 15 2020)
Python Projects, Coaching and Support ... https://www.egenix.com/ Python Product Development ... https://consulting.egenix.com/
::: We implement business ideas - efficiently in both time and costs :::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 https://www.egenix.com/company/contact/ https://www.malemburg.com/