Adopt multi-phase initialisation (PEP 489)#495
Conversation
| #ifdef Py_mod_gil // Python 3.13+ | ||
| {Py_mod_gil, Py_MOD_GIL_NOT_USED}, | ||
| #endif |
There was a problem hiding this comment.
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.
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