diff options
author | Victor Stinner <vstinner@python.org> | 2020-03-12 23:18:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-12 23:18:39 +0100 |
commit | 0b72b23fb0c130279f65f3bcd23521acf4a98c88 (patch) | |
tree | 2e2bbdef31294861783eeea4da94a02b8715f4c9 /Python/ceval.c | |
parent | c846ef004d79ee8e9645d3e5e8b3b0cb97b5013f (diff) | |
download | cpython-git-0b72b23fb0c130279f65f3bcd23521acf4a98c88.tar.gz |
bpo-38500: Add _PyInterpreterState_SetEvalFrameFunc() (GH-17340)
PyInterpreterState.eval_frame function now requires a tstate (Python
thread state) parameter.
Add private functions to the C API to get and set the frame
evaluation function:
* Add tstate parameter to _PyFrameEvalFunction function type.
* Add _PyInterpreterState_GetEvalFrameFunc() and
_PyInterpreterState_SetEvalFrameFunc() functions.
* Add tstate parameter to _PyEval_EvalFrameDefault().
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 380212a71a..ccd1c06a39 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -725,9 +725,7 @@ PyEval_EvalCode(PyObject *co, PyObject *globals, PyObject *locals) PyObject * PyEval_EvalFrame(PyFrameObject *f) { - /* This is for backward compatibility with extension modules that - used this API; core interpreter code should call - PyEval_EvalFrameEx() */ + /* Function kept for backward compatibility */ PyThreadState *tstate = _PyThreadState_GET(); return _PyEval_EvalFrame(tstate, f, 0); } @@ -740,8 +738,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) } PyObject* _Py_HOT_FUNCTION -_PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) +_PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) { + ensure_tstate_not_null(__func__, tstate); + #ifdef DXPAIRS int lastopcode = 0; #endif @@ -756,9 +756,6 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) _Py_atomic_int * const eval_breaker = &ceval->eval_breaker; PyCodeObject *co; - PyThreadState * const tstate = _PyRuntimeState_GetThreadState(runtime); - ensure_tstate_not_null(__func__, tstate); - /* when tracing we set things up so that not (instr_lb <= current_bytecode_offset < instr_ub) @@ -1181,7 +1178,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) goto error; #ifdef Py_DEBUG - /* PyEval_EvalFrameEx() must not be called with an exception set, + /* _PyEval_EvalFrameDefault() must not be called with an exception set, because it can clear it (directly or indirectly) and so the caller loses its exception */ assert(!_PyErr_Occurred(tstate)); @@ -3702,7 +3699,7 @@ exit_eval_frame: f->f_executing = 0; tstate->frame = f->f_back; - return _Py_CheckFunctionResult(tstate, NULL, retval, "PyEval_EvalFrameEx"); + return _Py_CheckFunctionResult(tstate, NULL, retval, __func__); } static void |