[Python-Dev] SET_LINENO and python options

Vladimir Marangozov Vladimir.Marangozov@inrialpes.fr
Mon, 31 Jul 2000 12:16:17 +0200 (CEST)


M.-A. Lemburg wrote:
> 
> [Vladimir on removing SET_LINENO opcodes per default]
> 
> Is there any reason why we can't just use traceback.tb_lineno()
> + maybe an equivalent C function instead of adding useless opcodes
> into the byte code stream ?
> 

Yes - you seem to have missed half the story <wink>. How would you
generate callbacks (fire "line" events) from within the mainloop
when a sys.settrace function is set and the PC starts executing
opcodes corresponding to a new line number?

Note that we don't "add" any new opcodes, and in the scheme I presented
CALL_TRACE is also internal to eval_code2(), like the copy of co_code,
but I eventually decided to show it in opcodes.h.

SET_LINENO is not generated anymore and is reduced to a NOOP in ceval,
CALL_TRACE is introduced only for the callbacks. For b/w compatibility
(of .pyc files) I think we can't just "get rid" of it.

And now that the game is over with finding the solution to f.f_lineno's
access, the proposal about "python -g" which preserves SET_LINENO makes
sense (at least for visualizing SET_LINENO in a disassembly).

-- 
       Vladimir MARANGOZOV          | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252