Newbie question - Getting current line number in embedded python
dcalvelo at pharion.univ-lille2.fr
Mon Sep 4 12:41:18 CEST 2000
Guido Piasenza <g.piasenza at fidia.it> wrote:
: I am currently evaluating different scripting languages to
: embed in a plc-like application. So far embedded python
: looks very promising, but I have a problem: once I call
: PyEval_EvalCode on a precompiled code object (created through
: PyNode_Compile) I would like to know what line number
: of my source file is being executed (in a different thread,
: of course).
You have the line number in the bytecode:
>>> def initive( arguments ):
... say = None
... print "remarks"
The '\177' bytecode is LINENO; the two following bytes are the line
: I browsed the source code of the executor and found that
: there is an endless loop (in eval_code2) which extracts
: opcodes and executes them, so I think this would be a
: nice place to wedge some code to extract this information.
: However, I found no way to get the "current line number"
: from the code block. I still have the parse tree and the
: compiled block stored in my application... do I have any
: way to map the offset of the current instruction to the
: node which previously generated it during the compilation
: phase ? Or any other way to extract the current line number ?
If you fiddle with eval_code2, then yes, sure, use the bytecode.
-- Daniel Calvelo Aros
calvelo at lifl.fr
More information about the Python-list