-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-110397: Add Py_IsFinalizing() to the stable ABI #110441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@ericsnowcurrently @serhiy-storchaka: @wjakob explains that reimplementing this function with the existing limited C API is likely to crash if calling during or after Python finalization. See: #110397 (comment) Would you be ok to add Py_IsFinalizing() directly to the limited C API version 3.13, knowing that this function was added to Python 3.13? This Py_IsFinalizing() function looks special and it's hard to workaround the lack of this API with the stable ABI. |
I'm fine with adding it to the Stable ABI, FWIW. |
FWIW, before we add the function to the stable ABI, it may be worth being clear about what "finalizing" means here. Consequently, we should consider actually making the I've written up my thoughts in detail in gh-110490. I realize that the stable ABI (and limited API) are specifically focused on memory layout, function signatures, and symbols (so it isn't critical if we change behavior later). Yet, there is also an implication of semantic stability (within reason) that we should avoid setting ourselves up to later break with this function. On the other hand, a different name might make sense, so we should avoid locking the symbol into the ABI prematurely. |
This API is just the same as |
@ericsnowcurrently: I merged this PR since I'm feeling responsible of breaking applications relying on Python 3.12 private _Py_IsFinalizing() API. This C API exposes Python For sure, there is always room for enhancement. It's a very complex topic, I wrote articles about it and I'm keeping notes about it: Python Finalization. While it's possible to enhance the API, make finalization more reliable, reduce the risk of crashes, IMO we need "something" for people who are already affected by known issues. @wjakob elaborated issues that this API is solving in #110397 (comment) and just for that, I think that such API is worth it. Python 3.13 didn't get an alpha1 release. We still have time until October 2024 to refine the documentation, the function name, come with a better API, etc. There is a non-zero risk that we will keep the name and so we will be good :-) |
|
Py_IsFinalizing()
to the limited API/stable ABI #110397📚 Documentation preview 📚: https://cpython-previews--110441.org.readthedocs.build/