Python Debugger which supports Black Boxing?

282 Views Asked by At

If I use the debugger, most of the times I just want to see what the interpreter does in my code. I want to step over all code of the framework and libraries I use.

AFAIK this is called Black Boxing.

How can I do this with Python ipdb or an other Python debugger?

Imagine this:

I use a orm framework which I trust, and don't want to debug.

cut_hair_method(orm_object.user)

The method cut_hair_method() is mine, and I want to debug it.

The orm_object is from the framework I use. The debugger will step into the orm-code and do some special things, which I don't care about. I have no way to tell the debugger: Don't jump into the orm code!

Update

For my case it would be very easy to decide which code should be in the black box and which code not: Code in $VIRTUAL_ENV/src/ is not in the black box, all other code is. Except I explicitly tell the debugger something else.

Update2

I have the name "Black Boxing" from this article: https://hacks.mozilla.org/2013/08/new-features-of-firefox-developer-tools-episode-25/

2

There are 2 best solutions below

0
On BEST ANSWER

The Python debugger base class (bdb.Bdb) has an a .skip attribute, giving a list of module names to skip over. You can provide this list either when instantiation the debugger, or later. If you want to provide a negative list (list of module that are your own), or otherwise compute whether a module should be skipped, you can subclass the debugger class and override is_skipped_module.

0
On

Since PyCharm version 4.5 there is a feature called "Step into my code": https://www.jetbrains.com/pycharm/whatsnew/#StepIntoCode

It works. I my case, I just want to step into my code (Django application), but not into the code of django itself. The default short-cut is complicated (alt-shift-F7) but it is easy to change it.

Related issue: https://youtrack.jetbrains.com/issue/PY-14789