-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
The PyOS_* hooks interact poorly with subinterpreters #104668
Copy link
Copy link
Closed
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItopic-subinterpreterstopic-tkintertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItopic-subinterpreterstopic-tkintertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
Done
PyOS_InputHookandPyOS_ReadlineFunctionPointerare globally-registeredinputhooks that have no way of recovering module-level state for the extensions that registered them. In practice, extensions likereadlineandtkinterget around this by using global state, which obviously isn't subinterpreter-friendly.What's more, extensions without advertised subinterpreter support (like
readlineandtkinter) who register these hooks might find themselves called from within a subinterpreter (where their extension hasn't even been loaded). That's definitely a situation we want to avoid.It seems like the best solution for 3.12 is to only call these hooks from the main interpreter, which makes the bad situation quite a bit better. If libraries really need better APIs that work per-interpreter and have ways to access module state, we can certainly add them later (but for now maybe we'll just cross our fingers and hope that nobody actually cares).
@ericsnowcurrently, how does this sound to you?
Linked PRs
PyOS_*hooks in subinterpreters #104674