gh-110397: Add Py_IsFinalizing() to the stable ABI by vstinner · Pull Request #110441 · python/cpython · GitHub
Skip to content

gh-110397: Add Py_IsFinalizing() to the stable ABI#110441

Merged
vstinner merged 1 commit intopython:mainfrom
vstinner:is_finalizing_stable_abi
Oct 7, 2023
Merged

gh-110397: Add Py_IsFinalizing() to the stable ABI#110441
vstinner merged 1 commit intopython:mainfrom
vstinner:is_finalizing_stable_abi

Conversation

@vstinner
Copy link
Copy Markdown
Member

@vstinner vstinner commented Oct 5, 2023

@vstinner
Copy link
Copy Markdown
Member Author

vstinner commented Oct 5, 2023

@erlend-aasland
Copy link
Copy Markdown
Contributor

I'm fine with adding it to the Stable ABI, FWIW.

@ericsnowcurrently
Copy link
Copy Markdown
Member

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 Py_IsFinalizing() behavior match its name or change the name.

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.

@vstinner
Copy link
Copy Markdown
Member Author

vstinner commented Oct 6, 2023

FWIW, before we add the function to the stable ABI, it may be worth being clear about what "finalizing" means here.

This API is just the same as sys.is_finalizing() which is already part of the "stable" Python API.

@vstinner vstinner marked this pull request as ready for review October 7, 2023 15:57
@vstinner vstinner requested review from a team and encukou as code owners October 7, 2023 15:57
@vstinner vstinner merged commit 64f158e into python:main Oct 7, 2023
@vstinner vstinner deleted the is_finalizing_stable_abi branch October 7, 2023 15:59
@vstinner
Copy link
Copy Markdown
Member Author

vstinner commented Oct 7, 2023

@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 sys.is_finalizing() API which exists since Python 3.5.

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 :-)

@bedevere-bot
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants