forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
Description
To ensure access to Python is done soundly, we need to ensure that any code that interacts with the Python interpreter has an attached thread state (unless otherwise allowed). c.f. https://docs.python.org/3/c-api/init.html#thread-state-and-the-global-interpreter-lock
PyO3's Python<'py> token seems to model this pretty well, though it is not perfectly sound. I'm not sure if there is a perfectly sound design available today.
Until auto traits and negative traits allow expressing !Ungil, perhaps we can require types in CPython to unsafe impl manually to ensure that the invariants are upheld?