Exceptions versus Windows ERRORLEVEL

Eryk Sun eryksun at gmail.com
Mon Apr 6 01:43:13 EDT 2020


On 4/3/20, Stephen Tucker <stephen_tucker at sil.org> wrote:
>
> Does an exception raised by a Python 3.x program on a Windows machine set
> ERRORLEVEL?

ERRORLEVEL is an internal state of the CMD shell. It has nothing to do
with Python. If Python exits due to an unhandled exception, the
process exit code will be 1. If CMD waits on the process, it will set
the ERRORLEVEL based on the exit code. But CMD doesn't always wait. By
default its START command doesn't wait. Also, at the interactive
command prompt it doesn't wait for non-console applications such as
"pythonw.exe"; it only waits for console applications such as
"python.exe".


More information about the Python-list mailing list