mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
GH-100719: Remove the co_nplaincellvars
field from code objects. (GH-100721)
This commit is contained in:
parent
c31e356a10
commit
15aecf8dd7
10 changed files with 19 additions and 23 deletions
|
@ -1357,8 +1357,8 @@ dummy_func(
|
|||
PyCodeObject *co = frame->f_code;
|
||||
assert(PyFunction_Check(frame->f_funcobj));
|
||||
PyObject *closure = ((PyFunctionObject *)frame->f_funcobj)->func_closure;
|
||||
int offset = co->co_nlocals + co->co_nplaincellvars;
|
||||
assert(oparg == co->co_nfreevars);
|
||||
int offset = co->co_nlocalsplus - oparg;
|
||||
for (int i = 0; i < oparg; ++i) {
|
||||
PyObject *o = PyTuple_GET_ITEM(closure, i);
|
||||
frame->localsplus[offset + i] = Py_NewRef(o);
|
||||
|
|
|
@ -3417,7 +3417,7 @@ format_exc_unbound(PyThreadState *tstate, PyCodeObject *co, int oparg)
|
|||
if (_PyErr_Occurred(tstate))
|
||||
return;
|
||||
name = PyTuple_GET_ITEM(co->co_localsplusnames, oparg);
|
||||
if (oparg < co->co_nplaincellvars + co->co_nlocals) {
|
||||
if (oparg < PyCode_GetFirstFree(co)) {
|
||||
format_exc_check_arg(tstate, PyExc_UnboundLocalError,
|
||||
UNBOUNDLOCAL_ERROR_MSG, name);
|
||||
} else {
|
||||
|
|
|
@ -2260,7 +2260,7 @@ compiler_make_closure(struct compiler *c, location loc,
|
|||
qualname = co->co_name;
|
||||
|
||||
if (co->co_nfreevars) {
|
||||
int i = co->co_nlocals + co->co_nplaincellvars;
|
||||
int i = PyCode_GetFirstFree(co);
|
||||
for (; i < co->co_nlocalsplus; ++i) {
|
||||
/* Bypass com_addop_varname because it will generate
|
||||
LOAD_DEREF but LOAD_CLOSURE is needed.
|
||||
|
|
2
Python/generated_cases.c.h
generated
2
Python/generated_cases.c.h
generated
|
@ -1575,8 +1575,8 @@
|
|||
PyCodeObject *co = frame->f_code;
|
||||
assert(PyFunction_Check(frame->f_funcobj));
|
||||
PyObject *closure = ((PyFunctionObject *)frame->f_funcobj)->func_closure;
|
||||
int offset = co->co_nlocals + co->co_nplaincellvars;
|
||||
assert(oparg == co->co_nfreevars);
|
||||
int offset = co->co_nlocalsplus - oparg;
|
||||
for (int i = 0; i < oparg; ++i) {
|
||||
PyObject *o = PyTuple_GET_ITEM(closure, i);
|
||||
frame->localsplus[offset + i] = Py_NewRef(o);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue