Qix- / better-exceptions

Pretty and useful exceptions in Python, automatically.
MIT License
4.6k stars 204 forks source link

PDB Integration #74

Open Netroxen opened 5 years ago

Netroxen commented 5 years ago

I'm currently using https://pypi.org/project/pdbpp/ as my debugger and was wondering if there's a way to hook better_exceptions into the .pdbrc.py file when a pdb statement or error occurs.

Any ideas on this..?

This is my current pdbrc configuration:

"""
This is an example configuration file for pdb++.
"""

import pdb

class Config(pdb.DefaultConfig):

    use_pygments = True
    disable_pytest_capturing = True
    stdin_paste = "epaste"
    filename_color = pdb.Color.lightgray
    use_terminal256formatter = False

    def __init__(self):
        try:
            from pygments.formatters import terminal
        except ImportError:
            pass
        else:
            self.colorscheme = terminal.TERMINAL_COLORS.copy()
            self.colorscheme.update(
                {
                    terminal.Keyword: ("darkred", "red"),
                    terminal.Number: ("darkyellow", "yellow"),
                    terminal.String: ("brown", "green"),
                    terminal.Name.Function: ("darkgreen", "blue"),
                    terminal.Name.Namespace: ("teal", "turquoise"),
                }
            )

    def setup(self, pdb):
        Pdb = pdb.__class__
        Pdb.do_l = Pdb.do_longlist
        Pdb.do_st = Pdb.do_sticky