On 7/21/20 5:04 PM, Gregory P. Smith wrote:
Given it is impossible for tools doing passive inspection of Python VM instances to execute code, co_linetable's exact format will be depended on just as co_lnotab was. co_lnotab was only quasi-"officially" documented in the Python docs, it's spec lives in https://github.com/python/cpython/blob/master/Objects/lnotab_notes.txt%C2%A0... to by a couple module's docs). The lnotab format "changed" once, in 3.6, an unsigned delta was changed to signed (but I don't believe anything beyond some experiments ever actually used negatives?).
Negatives definitely happen. When I comment out the line in coverage.py that deals with negative deltas, 34 of my tests fail.
a = ( 1 )
With 3.8 compiles to:
2 0 LOAD_CONST 0 (1)
1 2 STORE_NAME 0 (a) 4 LOAD_CONST 1 (None) 6 RETURN_VALUE
With an lnotab of "02 ff".
When executed, this produces these trace events:
call on line 1 line on line 2 line on line 1 return on line 1