Conversation
This reverts commit c0b11de.
Existance of co_code is used by debugging tools to detect the Code object
This is needed to have sys.settrace(fn) to not call fn() right away with its return.
|
When testing pdb/bdb with this branch, I understood that some source of tooling confusion is that the AST generator (or parser, idk) thing is marking "line 0" for lots of bytecodes, even far down ones. This is leading pdb to not reliably print the current line or perceiving where to stop after a step. I consider this a bug, even being an interpreter-dependent one. For some reason, I got to know PEP 626, accepted on CPython 3.10. It adds a I was having trouble trying to implement the co_lnotab for RustPython, and this can ease the whole implementation yet making the thing future-proof. Could I get some guidance on where/how to implement it? |
|
Yeah, I think co_lines seems better, especially if we're having issues with bytecode locations. For implementing, I think we could iterate through the |
|
Also, what are you planning on using the |
Well, not really. I needed Looking at the code of pdb and bdb, I saw nothing very specific to the bytecode format, which makes sense as the same pdb.py is used on PyPy for example, that have a different bytecode set than CPython. Implement Another thing is that, after pdb working, my next targets would be IPython, wdb and debugpy. This ones will probable need patches and maintenance. Implementing |
|
Ah, I also plan to implement PEP 3147 (aka |
|
This is where pdb.py indirectly uses def getsourcelines(obj):
lines, lineno = inspect.findsource(obj)
if inspect.isframe(obj) and obj.f_globals is obj.f_locals:
# must be a module frame: do not try to cut a block out of it
return lines, 1
elif inspect.ismodule(obj):
return lines, 1
return inspect.getblock(lines[lineno:]), lineno+1
def lasti2lineno(code, lasti):
linestarts = list(dis.findlinestarts(code))
linestarts.reverse()
for i, lineno in linestarts:
if lasti >= i:
return lineno
return 0Also, pdb.py sets |
I think that's already implemented, just by the importlib frozen module. Also, it looks like the way |
|
I was playing with an implementation of Will explore this path first. Thanks for the guidance. |
TBD