[issue40228] Make setting line number in frame more robust.

STINNER Victor report at bugs.python.org
Thu May 7 17:53:51 EDT 2020


STINNER Victor <vstinner at python.org> added the comment:

Windows 64-bit emits a compiler warning on this line:

    int len = PyBytes_GET_SIZE(f->f_code->co_code)/sizeof(_Py_CODEUNIT);

Warning:

D:\a\cpython\cpython\Objects\frameobject.c(400,1): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]

Either the code should be rewritten to to Py_ssize_t, or the result should be downcasted to int.

Technically, it seems possible to create a code object larger than INT_MAX instructors: PyCode_New() has no limit on the bytecode length.

----------
nosy: +vstinner

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40228>
_______________________________________


More information about the Python-bugs-list mailing list