2

When a script ends with an error during debugging, PyCharm got disconnected from pydev. So, the state of variable at the moment of the error remains unknown.

How can I find out the very latest values of variables right before the error happens?

Updated: This problem arises only when you try to debug a unit test. You have to check "Activation policy: On raise" for "All Breakpoints" in the list of breakpoints.

2
  • 2
    to the best of my knowledge, pycharm does not use pydev. So it's hard to get a lock on what your issue is. Secondly, look into try/catch structures. Third, are you sure you want to do print debugging, as opposed to use a nice debugger itself? Commented Aug 24, 2014 at 16:53
  • @inspectorG4dget I run PyCharm's debugger (and it says "Connected to pydev debugger (build 135.1057) pydev debugger: process 28034 is connecting"). Commented Aug 24, 2014 at 17:14

1 Answer 1

4

The simplest solution would be setting a breakpoint just before/at the wanted line so you can see the variables just before the exception is called.

It's also possible to set an "exception breakpoint". This stops the script when a specific exception is encountered. Open "Run" > "View Breakpoints", click on the "+" sign and add a "Python Exception Breakpoint". Now you have to choose a specific exception.

Sign up to request clarification or add additional context in comments.

2 Comments

In this case, you delete the previous breakpoint and add an "exception breakpoint". Open Run > View Breakpoints, click on the "+" sign and add a "Python Exception Breakpoint". Now you have to choose a specific exception. That's it.
That's it. Thanks a lot. Maybe worth adding to the post itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.