diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-01-04 13:37:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-04 13:37:06 (GMT) |
commit | c31e356a10aa60b5967b9aaf80b9984059e46461 (patch) | |
tree | 774e48afaea4e83f9b14c46e8d20cc14e018d92d /Objects/genobject.c | |
parent | 5fb1c08e15b864d8ea9353a0e013166e2e0e2160 (diff) | |
download | cpython-c31e356a10aa60b5967b9aaf80b9984059e46461.zip cpython-c31e356a10aa60b5967b9aaf80b9984059e46461.tar.gz cpython-c31e356a10aa60b5967b9aaf80b9984059e46461.tar.bz2 |
gh-100720: refactor calculation of number of frame slots for a code object into the new function _PyFrame_NumSlotsForCodeObject (#100722)
Diffstat (limited to 'Objects/genobject.c')
-rw-r--r-- | Objects/genobject.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c index c006f1a..ea3382d 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -769,7 +769,7 @@ gen_sizeof(PyGenObject *gen, PyObject *Py_UNUSED(ignored)) Py_ssize_t res; res = offsetof(PyGenObject, gi_iframe) + offsetof(_PyInterpreterFrame, localsplus); PyCodeObject *code = gen->gi_code; - res += (code->co_nlocalsplus+code->co_stacksize) * sizeof(PyObject *); + res += _PyFrame_NumSlotsForCodeObject(code) * sizeof(PyObject *); return PyLong_FromSsize_t(res); } @@ -850,7 +850,7 @@ static PyObject * make_gen(PyTypeObject *type, PyFunctionObject *func) { PyCodeObject *code = (PyCodeObject *)func->func_code; - int slots = code->co_nlocalsplus + code->co_stacksize; + int slots = _PyFrame_NumSlotsForCodeObject(code); PyGenObject *gen = PyObject_GC_NewVar(PyGenObject, type, slots); if (gen == NULL) { return NULL; |