mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-36710: Pass explicitly tstate in sysmodule.c (GH-14060)
* Replace global var Py_VerboseFlag with interp->config.verbose. * Add _PyErr_NoMemory(tstate) function. * Add tstate parameter to _PyEval_SetCoroutineOriginTrackingDepth() and move the function to the internal API. * Replace _PySys_InitMain(runtime, interp) with _PySys_InitMain(runtime, tstate).
This commit is contained in:
parent
3498c642f4
commit
838f26402d
8 changed files with 263 additions and 179 deletions
|
@ -4728,10 +4728,9 @@ PyEval_SetTrace(Py_tracefunc func, PyObject *arg)
|
|||
}
|
||||
|
||||
void
|
||||
_PyEval_SetCoroutineOriginTrackingDepth(int new_depth)
|
||||
_PyEval_SetCoroutineOriginTrackingDepth(PyThreadState *tstate, int new_depth)
|
||||
{
|
||||
assert(new_depth >= 0);
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
tstate->coroutine_origin_tracking_depth = new_depth;
|
||||
}
|
||||
|
||||
|
|
|
@ -547,9 +547,8 @@ PyErr_BadArgument(void)
|
|||
}
|
||||
|
||||
PyObject *
|
||||
PyErr_NoMemory(void)
|
||||
_PyErr_NoMemory(PyThreadState *tstate)
|
||||
{
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
if (Py_TYPE(PyExc_MemoryError) == NULL) {
|
||||
/* PyErr_NoMemory() has been called before PyExc_MemoryError has been
|
||||
initialized by _PyExc_Init() */
|
||||
|
@ -560,6 +559,13 @@ PyErr_NoMemory(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
PyErr_NoMemory(void)
|
||||
{
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
return _PyErr_NoMemory(tstate);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
PyErr_SetFromErrnoWithFilenameObject(PyObject *exc, PyObject *filenameObject)
|
||||
{
|
||||
|
|
|
@ -899,6 +899,7 @@ pyinit_main(_PyRuntimeState *runtime, PyInterpreterState *interp)
|
|||
}
|
||||
|
||||
/* Configure the main interpreter */
|
||||
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
|
||||
PyConfig *config = &interp->config;
|
||||
|
||||
if (runtime->initialized) {
|
||||
|
@ -919,7 +920,7 @@ pyinit_main(_PyRuntimeState *runtime, PyInterpreterState *interp)
|
|||
return _PyStatus_ERR("can't initialize time");
|
||||
}
|
||||
|
||||
if (_PySys_InitMain(runtime, interp) < 0) {
|
||||
if (_PySys_InitMain(runtime, tstate) < 0) {
|
||||
return _PyStatus_ERR("can't finish initializing sys");
|
||||
}
|
||||
|
||||
|
@ -1456,7 +1457,7 @@ new_interpreter(PyThreadState **tstate_p)
|
|||
}
|
||||
Py_INCREF(interp->sysdict);
|
||||
PyDict_SetItemString(interp->sysdict, "modules", modules);
|
||||
if (_PySys_InitMain(runtime, interp) < 0) {
|
||||
if (_PySys_InitMain(runtime, tstate) < 0) {
|
||||
return _PyStatus_ERR("can't finish initializing sys");
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue