At the moment, the dbg implementation walks up the stack to find a line with "dbg" in it:
|
for i in reversed(inspect.stack()): |
|
ctx = i.code_context[0] |
|
if "dbg" in ctx: |
Considering the fact that the expected use-case of this function is to put it literally in the code (and not pass around as a callback), I think it's safe to limit the stack lookup to only one level.
If we do that, we can then improve the context lookup to walk back on the line-of-code (to some maximum of like, 10) and print those out as the context for the call.
What do you think?
At the moment, the
dbgimplementation walks up the stack to find a line with"dbg"in it:pydbg/pydbg.py
Lines 27 to 29 in 4d787cd
Considering the fact that the expected use-case of this function is to put it literally in the code (and not pass around as a callback), I think it's safe to limit the stack lookup to only one level.
If we do that, we can then improve the context lookup to walk back on the line-of-code (to some maximum of like, 10) and print those out as the context for the call.
What do you think?