Skip to content

bpo-36710: Pass explicitly tstate in sysmodule.c #14060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Include/ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj,
#ifndef Py_LIMITED_API
PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
PyAPI_FUNC(void) _PyEval_SetCoroutineOriginTrackingDepth(int new_depth);
PyAPI_FUNC(int) _PyEval_GetCoroutineOriginTrackingDepth(void);
PyAPI_FUNC(void) _PyEval_SetAsyncGenFirstiter(PyObject *);
PyAPI_FUNC(PyObject *) _PyEval_GetAsyncGenFirstiter(void);
Expand Down
3 changes: 3 additions & 0 deletions Include/internal/pycore_ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ PyAPI_FUNC(void) _PyEval_SignalAsyncExc(
struct _ceval_runtime_state *ceval);
PyAPI_FUNC(void) _PyEval_ReInitThreads(
_PyRuntimeState *runtime);
PyAPI_FUNC(void) _PyEval_SetCoroutineOriginTrackingDepth(
PyThreadState *tstate,
int new_depth);

/* Private function */
void _PyEval_Fini(void);
Expand Down
2 changes: 2 additions & 0 deletions Include/internal/pycore_pyerrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ PyAPI_FUNC(void) _PyErr_Clear(PyThreadState *tstate);

PyAPI_FUNC(void) _PyErr_SetNone(PyThreadState *tstate, PyObject *exception);

PyAPI_FUNC(PyObject *) _PyErr_NoMemory(PyThreadState *tstate);

PyAPI_FUNC(void) _PyErr_SetString(
PyThreadState *tstate,
PyObject *exception,
Expand Down
2 changes: 1 addition & 1 deletion Include/internal/pycore_pylifecycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extern PyStatus _PySys_Create(
extern PyStatus _PySys_SetPreliminaryStderr(PyObject *sysdict);
extern int _PySys_InitMain(
_PyRuntimeState *runtime,
PyInterpreterState *interp);
PyThreadState *tstate);
extern PyStatus _PyImport_Init(PyInterpreterState *interp);
extern PyStatus _PyExc_Init(void);
extern PyStatus _PyErr_Init(void);
Expand Down
3 changes: 1 addition & 2 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
10 changes: 8 additions & 2 deletions Python/errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -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() */
Expand All @@ -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)
{
Expand Down
5 changes: 3 additions & 2 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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");
}

Expand Down Expand Up @@ -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");
}
}
Expand Down
Loading