1

I've been using the debugger in spyder and experimenting with the 'Set/Edit Conditional Breakpoint' functionality. See the code snippet below; where I set the breakpoint condition to i==2 on line 4 the IPdb will pause the code nicely when i is equal to 2 and I can inspect my variables in the variable explorer.

What I'd really like to do is set a conditional breakpoint to only trigger when a certain type of error is raised, therefore allowing me to inspect the variables that caused the error. When I set the conditional breakpoint to simply be: ValueError, it does not trigger when there's an error. Is setting a conditional breakpoint to only trigger when an error is raised possible, and if so, what is the correct syntax?

1  my_list = [1.4, 1.8, 'some text', 4.1]
2
3  for i, value in enumerate(my_list):
4      value_int = int(value)

I've been running this with the following: Spyder==5 & Python==3.10

  • 1
    One possible work around that I've noticed is to click on Run > Configuration per file... > Select 'Run file with custom configuration' > Select (under general settings) 'Directly enter debugging when errors appear'. This enters 'post mortem debugging' which then shows the variables (including those defined within functions) at the time of error in the variable explorer. – Matt_Haythornthwaite Aug 17 '23 at 14:20
  • 1
    (*Spyder maintainer here*) That was going to be precisely my suggestion. You can introduce errors by adding a line like `raise ValueError` at any point in your code. And then Spyder will start a debugging session if the option you mentioned is enabled. – Carlos Cordoba Aug 21 '23 at 17:48

0 Answers0