Skip to content

Expand print context instead of climbing up the stack #10

Description

@besfahbod

At the moment, the dbg implementation walks up the stack to find a line with "dbg" in it:

pydbg/pydbg.py

Lines 27 to 29 in 4d787cd

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions