bpo-45355: Use sizeof(_Py_CODEUNIT) instead of literal 2 for the size of the code unit (GH-28711)

This commit is contained in:
Serhiy Storchaka 2021-10-03 21:22:42 +03:00 committed by GitHub
parent 4f6e0680d0
commit 60b9e040c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 15 deletions

View file

@ -45,7 +45,7 @@ PyFrame_GetLineNumber(PyFrameObject *f)
return f->f_lineno;
}
else {
return PyCode_Addr2Line(f->f_frame->f_code, f->f_frame->f_lasti*2);
return PyCode_Addr2Line(f->f_frame->f_code, f->f_frame->f_lasti*sizeof(_Py_CODEUNIT));
}
}
@ -67,7 +67,7 @@ frame_getlasti(PyFrameObject *f, void *closure)
if (f->f_frame->f_lasti < 0) {
return PyLong_FromLong(-1);
}
return PyLong_FromLong(f->f_frame->f_lasti*2);
return PyLong_FromLong(f->f_frame->f_lasti*sizeof(_Py_CODEUNIT));
}
static PyObject *

View file

@ -1284,7 +1284,7 @@ compute_cr_origin(int origin_depth)
PyCodeObject *code = frame->f_code;
PyObject *frameinfo = Py_BuildValue("OiO",
code->co_filename,
PyCode_Addr2Line(frame->f_code, frame->f_lasti*2),
PyCode_Addr2Line(frame->f_code, frame->f_lasti*sizeof(_Py_CODEUNIT)),
code->co_name);
if (!frameinfo) {
Py_DECREF(cr_origin);