diff options
author | T. Wouters <thomas@python.org> | 2019-09-28 14:49:15 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@krypto.org> | 2019-09-28 14:49:15 (GMT) |
commit | c8165036f374cd2ee64d4314eeb2514f7acb5026 (patch) | |
tree | 457ae87d81e9ec7ee50e538302d069e28cf79287 /Objects | |
parent | 7774d7831e8809795c64ce27f7df52674581d298 (diff) | |
download | cpython-c8165036f374cd2ee64d4314eeb2514f7acb5026.zip cpython-c8165036f374cd2ee64d4314eeb2514f7acb5026.tar.gz cpython-c8165036f374cd2ee64d4314eeb2514f7acb5026.tar.bz2 |
bpo-38115: Deal with invalid bytecode offsets in lnotab (GH-16079)
Document that lnotab can contain invalid bytecode offsets (because of
terrible reasons that are difficult to fix). Make dis.findlinestarts()
ignore invalid offsets in lnotab. All other uses of lnotab in CPython
(various reimplementations of addr2line or line2addr in Python, C and gdb)
already ignore this, because they take an address to look for, instead.
Add tests for the result of dis.findlinestarts() on wacky constructs in
test_peepholer.py, because it's the easiest place to add them.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/lnotab_notes.txt | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/lnotab_notes.txt b/Objects/lnotab_notes.txt index 3dab2b9..71a2979 100644 --- a/Objects/lnotab_notes.txt +++ b/Objects/lnotab_notes.txt @@ -3,7 +3,9 @@ All about co_lnotab, the line number table. Code objects store a field named co_lnotab. This is an array of unsigned bytes disguised as a Python bytes object. It is used to map bytecode offsets to source code line #s for tracebacks and to identify line number boundaries for -line tracing. +line tracing. Because of internals of the peephole optimizer, it's possible +for lnotab to contain bytecode offsets that are no longer valid (for example +if the optimizer removed the last line in a function). The array is conceptually a compressed list of (bytecode offset increment, line number increment) |