Skip to content Skip to sidebar Skip to footer

Cathing Sys.exit() In Debugger

My programme ends unexpectedly. When I run it through pdb, it ends with: The program exited via sys.exit(). Exit status:

Solution 1:

A simple-ish solution would be to monkey-patch sys.exit() before running:

$ python -m pdb my_script.py

(Pdb) def no_exit(code): raise RuntimeError('halt')
(Pdb) import sys
(Pdb) sys.exit = no_exit
(Pdb) cont

Post a Comment for "Cathing Sys.exit() In Debugger"