This project has moved and is read-only. For the latest updates, please go here.

Stepping Through Code

Sep 25, 2013 at 6:06 PM
I'm trying to step into Python code that I'm referencing from site-packages and it doesn't work when pressing F11 on the call line. However, when go the definition of the called function (F12) and put a breakpoint in it, the code is stopped as intended and I'm allowed to do the usual things such as inspect variables etc. However, after this if at any point within the called function I try to step through line by line (F10) it exits the called function and jumps straight out to the calling code. I can do something similar to stepping through be putting lots of breakpoints in the called function, hitting F5 and then it stops correctly at these points.

Is this a known bug, or am I doing something incorrect here? It would be nice to step into called functions and then step through them once there. Even though it can be achieved by putting in multiple breakpoints it does get a bit tedious doing this.
Sep 25, 2013 at 6:12 PM
It's slightly odd behaviour, but the cause is that we typically step over files in the standard library (and hence, site-packages).

To change this option, go to Tools->Options->Python Tools->Debugging and check "Enable debugging of the Python standard library". This will disable our checks and let you step through the code.
Sep 25, 2013 at 6:30 PM
OK thanks, this works in principle

However, when my calling code contains an import of numpy I get exceptions thrown during this import, as I've put in the previous thread here. Rather than one exception be thrown (as was happening before I changed the configuration as suggested above), literally hundreds of exceptions are thrown. I've tried repeatedly pressing F5 to get through all of them to back to my main code but so many exceptions occur one after the other that I eventually give up.
Sep 25, 2013 at 7:56 PM
Yes, it's not a perfect setup unfortunately. Changing that setting means you've opted in to everything that comes with treating the standard library as if it's part of your project, and we assume you want to know about exceptions. We have some special handling on Python 3.3+ for exceptions while importing, but we can't do the same on earlier versions as easily. You can disable breaking on exceptions through the Debug->Exceptions menu.

However, a better option may be to make a private copy of the library you're debugging in your project folder (and disabling the standard library option). That way we'll treat it as if it belongs to you and you'll get full debugging.