GH-104668: Don't call PyOS_* hooks in subinterpreters (GH-104674)

This commit is contained in:
Brandt Bucher 2023-05-22 12:34:34 -07:00 committed by GitHub
parent 2c4e29e322
commit 357bed0bcd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 7 deletions

View file

@ -167,6 +167,10 @@ the same library that the Python runtime is using.
event loops, as done in the :file:`Modules/_tkinter.c` in the
Python source code.
.. versionchanged:: 3.12
This function is only called from the
:ref:`main interpreter <sub-interpreter-support>`.
.. c:var:: char* (*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *)
@ -187,6 +191,10 @@ the same library that the Python runtime is using.
:c:func:`PyMem_RawRealloc`, instead of being allocated by
:c:func:`PyMem_Malloc` or :c:func:`PyMem_Realloc`.
.. versionchanged:: 3.12
This function is only called from the
:ref:`main interpreter <sub-interpreter-support>`.
.. c:function:: PyObject* PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals)
This is a simplified interface to :c:func:`PyRun_StringFlags` below, leaving

View file

@ -1476,6 +1476,15 @@ Porting to Python 3.12
Note that :c:func:`PyType_FromMetaclass` (added in Python 3.12)
already disallows creating classes whose metaclass overrides ``tp_new``.
* :c:var:`PyOS_InputHook` and :c:var:`PyOS_ReadlineFunctionPointer` are no
longer called in :ref:`subinterpreters <sub-interpreter-support>`. This is
because clients generally rely on process-wide global state (since these
callbacks have no way of recovering extension module state).
This also avoids situations where extensions may find themselves running in a
subinterpreter that they don't support (or haven't yet been loaded in). See
:gh:`104668` for more info.
Deprecated
----------