mirror of
https://github.com/python/cpython.git
synced 2025-08-23 10:16:01 +00:00
gh-76785: Add More Tests to test_interpreters.test_api (gh-117662)
In addition to the increase test coverage, this is a precursor to sorting out how we handle interpreters created directly via the C-API.
This commit is contained in:
parent
0cc71bde00
commit
993c3cca16
18 changed files with 2015 additions and 421 deletions
|
@ -477,6 +477,7 @@ pyinit_core_reconfigure(_PyRuntimeState *runtime,
|
|||
if (interp == NULL) {
|
||||
return _PyStatus_ERR("can't make main interpreter");
|
||||
}
|
||||
assert(interp->_ready);
|
||||
|
||||
status = _PyConfig_Write(config, runtime);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
|
@ -631,6 +632,8 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
|
|||
}
|
||||
assert(interp != NULL);
|
||||
assert(_Py_IsMainInterpreter(interp));
|
||||
_PyInterpreterState_SetWhence(interp, _PyInterpreterState_WHENCE_RUNTIME);
|
||||
interp->_ready = 1;
|
||||
|
||||
status = _PyConfig_Copy(&interp->config, src_config);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
|
@ -2120,7 +2123,8 @@ Py_Finalize(void)
|
|||
*/
|
||||
|
||||
static PyStatus
|
||||
new_interpreter(PyThreadState **tstate_p, const PyInterpreterConfig *config)
|
||||
new_interpreter(PyThreadState **tstate_p,
|
||||
const PyInterpreterConfig *config, long whence)
|
||||
{
|
||||
PyStatus status;
|
||||
|
||||
|
@ -2143,6 +2147,8 @@ new_interpreter(PyThreadState **tstate_p, const PyInterpreterConfig *config)
|
|||
*tstate_p = NULL;
|
||||
return _PyStatus_OK();
|
||||
}
|
||||
_PyInterpreterState_SetWhence(interp, whence);
|
||||
interp->_ready = 1;
|
||||
|
||||
// XXX Might new_interpreter() have been called without the GIL held?
|
||||
PyThreadState *save_tstate = _PyThreadState_GET();
|
||||
|
@ -2231,15 +2237,17 @@ PyStatus
|
|||
Py_NewInterpreterFromConfig(PyThreadState **tstate_p,
|
||||
const PyInterpreterConfig *config)
|
||||
{
|
||||
return new_interpreter(tstate_p, config);
|
||||
long whence = _PyInterpreterState_WHENCE_CAPI;
|
||||
return new_interpreter(tstate_p, config, whence);
|
||||
}
|
||||
|
||||
PyThreadState *
|
||||
Py_NewInterpreter(void)
|
||||
{
|
||||
PyThreadState *tstate = NULL;
|
||||
long whence = _PyInterpreterState_WHENCE_LEGACY_CAPI;
|
||||
const PyInterpreterConfig config = _PyInterpreterConfig_LEGACY_INIT;
|
||||
PyStatus status = new_interpreter(&tstate, &config);
|
||||
PyStatus status = new_interpreter(&tstate, &config, whence);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
Py_ExitStatusException(status);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue