Skip to content

Commit

Permalink
bpo-43693: Do not check co_cell2arg if a non-cell offset. (pythongh-2…
Browse files Browse the repository at this point in the history
…6626)

This is the same fix as for PyFrame_LocalsToFast() in pythongh-26609, but applied to PyFrame_FastToLocalsWithError(). (It should have been in that PR.)

https://bugs.python.org/issue43693
  • Loading branch information
ericsnowcurrently authored Jun 9, 2021
1 parent eea8148 commit e6e34e4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,9 @@ PyFrame_FastToLocalsWithError(PyFrameObject *f)
PyObject *value = fast[i];
if (f->f_state != FRAME_CLEARED) {
int cellargoffset = CO_CELL_NOT_AN_ARG;
if (co->co_cell2arg != NULL) {
if (kind & CO_FAST_CELL && co->co_cell2arg != NULL) {
assert(i - co->co_nlocals >= 0);
assert(i - co->co_nlocals < co->co_ncellvars);
cellargoffset = co->co_cell2arg[i - co->co_nlocals];
}
if (kind & CO_FAST_FREE) {
Expand Down Expand Up @@ -1093,7 +1095,8 @@ PyFrame_LocalsToFast(PyFrameObject *f, int clear)
PyObject *oldvalue = fast[i];
int cellargoffset = CO_CELL_NOT_AN_ARG;
if (kind & CO_FAST_CELL && co->co_cell2arg != NULL) {
assert(i >= co->co_nlocals);
assert(i - co->co_nlocals >= 0);
assert(i - co->co_nlocals < co->co_ncellvars);
cellargoffset = co->co_cell2arg[i - co->co_nlocals];
}
PyObject *cell = NULL;
Expand Down

0 comments on commit e6e34e4

Please sign in to comment.