diff options
author | Mark Shannon <mark@hotpy.org> | 2023-01-04 15:41:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-04 15:41:39 (GMT) |
commit | 15aecf8dd70f82eb507d74fae9662072a377bdc8 (patch) | |
tree | 6afd6d35744428bafd5b64bc6fccbb830534c86e /Python | |
parent | c31e356a10aa60b5967b9aaf80b9984059e46461 (diff) | |
download | cpython-15aecf8dd70f82eb507d74fae9662072a377bdc8.zip cpython-15aecf8dd70f82eb507d74fae9662072a377bdc8.tar.gz cpython-15aecf8dd70f82eb507d74fae9662072a377bdc8.tar.bz2 |
GH-100719: Remove the `co_nplaincellvars` field from code objects. (GH-100721)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bytecodes.c | 2 | ||||
-rw-r--r-- | Python/ceval.c | 2 | ||||
-rw-r--r-- | Python/compile.c | 2 | ||||
-rw-r--r-- | Python/generated_cases.c.h | 2 |
4 files changed, 4 insertions, 4 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 839fac3..dec122a 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -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); diff --git a/Python/ceval.c b/Python/ceval.c index 45f4280..54df1c5 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -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 { diff --git a/Python/compile.c b/Python/compile.c index cbbdfb9..c2e77fe 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -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. diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index ed89e90..3218bd0 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -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); |