-
-
Notifications
You must be signed in to change notification settings - Fork 164
Adopt multi-phase initialisation (PEP 489) #495
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
#ifdef Py_mod_gil // Python 3.13+ | ||
{Py_mod_gil, Py_MOD_GIL_NOT_USED}, | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This replaces the PyUnstable_Module_SetGIL()
call, migrating away from experimental/unstable API.
NULL | ||
.m_base = PyModuleDef_HEAD_INIT, | ||
.m_name = "markupsafe._speedups", | ||
.m_size = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m_size
goes from -1
to 0
as we have no module state. -1
is a special sentinel indicating that the module may have global state, which we don't have here.
Failure seems unrelated: |
Do I need to do this somehow with PyO3 if we switch to Rust with #438? |
Many binding generators have support for multi-phase (Cython, Pybind, HPy, etc), but sadly PyO3 doesn't yet. There's a draft PR in PyO3/pyo3#5142, though. I'd be happy to help with multi-phase in Rust should you go forward with that PR; as mentioned this is useful in Sphinx for subinterpreter support so I have an incentive to help! A |
Rebased onto stable. Determined the new test doesn't require a subprocess call. It still fails when run on |
Thanks David! A |
Per #494, this PR effects multi-phase init for MarkupSafe.
I've also added a test to ensure things are working properly.
Thanks,
Adam