Mark Shannon <m...@hotpy.org> added the comment:

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.

----------
assignee:  -> Mark.Shannon

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42739>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to