Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code Python debugging "Exception has occurred SystemExit"

Tags:

I've been using Visual Studio code for a long time with the Python extension.

Currently I have Visual Studio Code version 1.27.2, Python extension "ms-python.python" version 2018.8.0, python version 3.6.6, hosted by a Windows 10 1803 Enterprise Edition system.

Compared to the past, the latest version of Code / MS Python behaves differently in the debugging process.

In the past the execution of the following Python code, within Visual Studio Code, would not have generated any exceptions:

# Import exit from sys from sys import exit as sys_exit # Exit to system with errorlevel set to 1 sys_exit(1) # Next instruction is never executed. # Executing the script directly from the terminal in Windows sets the # errorlevel to 1 and the script execution is terminated.  print('unreachable code') 

Now the result is a SystemExit exception when sys_exit(1) instruction is executed (VSCode screenshot).

Question: is there a way to disable this behavior and return to the previous one?

like image 693
Andrea Alberto Martinoli Avatar asked Sep 17 '18 17:09

Andrea Alberto Martinoli


1 Answers

I ran into something similar while debugging my flask application. My work-around was to uncheck "Uncaught Exceptions" in the breakpoint menu at the bottom of the debug window.

enter image description here

like image 132
Josh Rodstein Avatar answered Sep 23 '22 13:09

Josh Rodstein