Message384325
dis is able to handle code with no line numbers.
>>> def f(): pass
...
>>> co = f.__code__.replace(co_linetable=b'\xff')
>>> list(co.co_lines())
[]
>>> import dis
>>> dis.dis(co)
0 LOAD_CONST 0 (None)
2 RETURN_VALUE
The problem with the example Serhiy gives is that the line number table does not end in a sentinel value.
You shouldn't be creating code objects unless you really know what you are doing. I.e. never.
For manually created code objects that don't respect the invariants, any behavior is acceptable IMO. |
|
Date |
User |
Action |
Args |
2021-01-04 14:31:20 | Mark.Shannon | set | recipients:
+ Mark.Shannon, serhiy.storchaka, ammar2 |
2021-01-04 14:31:20 | Mark.Shannon | set | messageid: <1609770680.79.0.959405453476.issue42739@roundup.psfhosted.org> |
2021-01-04 14:31:20 | Mark.Shannon | link | issue42739 messages |
2021-01-04 14:31:20 | Mark.Shannon | create | |
|