Fix MSVC warning in frameobject.c#20590
Conversation
|
This fix doesn't work, I get a warning using GCC 10 on Fedora 32:
I'm not comfortable with relying on such assumption that things "should not happen in practice". I would prefer to implement a concrete runtime check in |
|
Hm, I got this warning too when I use gcc9.3 on Red Hat 4.8.5-36. |
|
Aah sorry about that. I was trying to go with a narrow fix and didn't want to touch too many files. It looks like there is an assertion here https://github.com/python/cpython/blob/master/Python/ceval.c#L1328 |
|
No problem :-) Follow-up PR: PR #20628. |
This should be a safe downcast as exceeding a size of
2^30opcodes in a single code object is extremely unlikely and there's already some hard dependencies relying on 32-bit ints likestruct _frame'sf_lasti,f_iblock. See PEP 611 for proposals to solidify this limit and other research on existing limits.While it would be possible to swap this out for a
Py_ssize_t, it would be a much more involved refactoring as line numbers are still reliant on being ints.