mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-76785: Crossinterp utils additions (gh-111530)
This moves several general internal APIs out of _xxsubinterpretersmodule.c and into the new Python/crossinterp.c (and the corresponding internal headers). Specifically: * _Py_excinfo, etc.: the initial implementation for non-object exception snapshots (in pycore_pyerrors.h and Python/errors.c) * _PyXI_exception_info, etc.: helpers for passing an exception beween interpreters (wraps _Py_excinfo) * _PyXI_namespace, etc.: helpers for copying a dict of attrs between interpreters * _PyXI_Enter(), _PyXI_Exit(): functions that abstract out the transitions between one interpreter and a second that will do some work temporarily Again, these were all abstracted out of _xxsubinterpretersmodule.c as generalizations. I plan on proposing these as public API at some point.
This commit is contained in:
parent
cde1071b2a
commit
9322ce90ac
11 changed files with 1309 additions and 472 deletions
|
|
@ -738,6 +738,7 @@ pycore_init_types(PyInterpreterState *interp)
|
|||
if (_PyStatus_EXCEPTION(status)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return _PyStatus_OK();
|
||||
}
|
||||
|
||||
|
|
@ -854,6 +855,11 @@ pycore_interp_init(PyThreadState *tstate)
|
|||
goto done;
|
||||
}
|
||||
|
||||
status = _PyXI_Init(interp);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
const PyConfig *config = _PyInterpreterState_GetConfig(interp);
|
||||
|
||||
status = _PyImport_InitCore(tstate, sysmod, config->_install_importlib);
|
||||
|
|
@ -1772,6 +1778,7 @@ finalize_interp_clear(PyThreadState *tstate)
|
|||
{
|
||||
int is_main_interp = _Py_IsMainInterpreter(tstate->interp);
|
||||
|
||||
_PyXI_Fini(tstate->interp);
|
||||
_PyExc_ClearExceptionGroupType(tstate->interp);
|
||||
_Py_clear_generic_types(tstate->interp);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue