Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
import tokenize
import traceback
import linecache
import _colorize

from contextlib import contextmanager
from rlcompleter import Completer
Expand Down Expand Up @@ -2303,7 +2304,7 @@ def main():
print("The program exited via sys.exit(). Exit status:", end=' ')
print(e)
except BaseException as e:
traceback.print_exc()
traceback.print_exception(e, colorize=_colorize.can_colorize())
print("Uncaught exception. Entering post mortem debugging")
print("Running 'cont' or 'step' will restart the program")
pdb.interaction(None, e)
Expand Down
4 changes: 3 additions & 1 deletion Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from contextlib import ExitStack, redirect_stdout
from io import StringIO
from test import support
from test.support import os_helper
from test.support import force_not_colorized, os_helper
from test.support.import_helper import import_module
from test.support.pty_helper import run_pty, FakeInput
from unittest.mock import patch
Expand Down Expand Up @@ -2918,6 +2918,7 @@ def start_pdb():
self.assertNotIn(b'Error', stdout,
"Got an error running test script under PDB")

@force_not_colorized
def test_issue16180(self):
# A syntax error in the debuggee.
script = "def f: pass\n"
Expand All @@ -2931,6 +2932,7 @@ def test_issue16180(self):
'Fail to handle a syntax error in the debuggee.'
.format(expected, stderr))

@force_not_colorized
def test_issue84583(self):
# A syntax error from ast.literal_eval should not make pdb exit.
script = "import ast; ast.literal_eval('')\n"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Print colorized exception just like built-in traceback in :mod:`pdb`