GH-100987: Don't cache references to the names and consts array in _PyEval_EvalFrameDefault. (#102640)

* Rename local variables, names and consts, from the interpeter loop. Will allow non-code objects in frames for better introspection of C builtins and extensions.

* Remove unused dummy variables.
This commit is contained in:
Mark Shannon 2023-03-13 18:35:37 +00:00 committed by GitHub
parent 634cb61909
commit 2d370da570
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 53 deletions

View file

@ -773,18 +773,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
/* Local "register" variables.
* These are cached values from the frame and code object. */
PyObject *names;
PyObject *consts;
_Py_CODEUNIT *next_instr;
PyObject **stack_pointer;
/* Sets the above local variables from the frame */
#define SET_LOCALS_FROM_FRAME() \
{ \
PyCodeObject *co = frame->f_code; \
names = co->co_names; \
consts = co->co_consts; \
} \
assert(_PyInterpreterFrame_LASTI(frame) >= -1); \
/* Jump back to the last instruction executed... */ \
next_instr = frame->prev_instr + 1; \