Question

I'm currently experimenting with lightweight debugging via Python.SetTrace(). But I cannot find a generic way from the callback parameters (TraceBackFrame stackFrame, string stEvent, object payload) to the ScriptSource containing the code.

I can map for the ScriptSource on which I initially called Execute(), by matching the file path (either ScriptSource.Path equals TraceBackFrame.f_code.co_filename, or the latter one is "string" when no file is involved).

But my search for any references pointing from the TraceBackFrame to the ScriptSource (which works for other python files executed by the script via import, exec, execfile etc.) was without success.

Thanks for any hints!

Was it helpful?

Solution

Just for the record: Our current solution is now to parse the source files on our own, if a file is available. For the stackframes not backed by a file (e. G. eval), we simply cannot trace them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top