Last active
August 15, 2021 14:13
-
-
Save juancarlospaco/539b2fba6c5152c317c8 to your computer and use it in GitHub Desktop.
ipdb on Exception AutoMagically!, Launch pdb or ipdb when an exception happens automatically.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pdb_on_exception(debugger="pdb", limit=100): | |
"""Install handler attach post-mortem pdb console on an exception.""" | |
pass | |
def pdb_excepthook(exc_type, exc_val, exc_tb): | |
traceback.print_tb(exc_tb, limit=limit) | |
__import__(str(debugger).strip().lower()).post_mortem(exc_tb) | |
sys.excepthook = pdb_excepthook | |
ipdb_on_exception = lambda: pdb_on_exception("ipdb") | |
# ptpdb_on_exception = lambda: pdb_on_exception("ptpdb") # See https://github.com/jonathanslenders/ptpdb/issues/14 |
Author
juancarlospaco
commented
Jan 17, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment