File tree 3 files changed +6
-2
lines changed 3 files changed +6
-2
lines changed Original file line number Diff line number Diff line change 84
84
import tokenize
85
85
import traceback
86
86
import linecache
87
+ import _colorize
87
88
88
89
from contextlib import contextmanager
89
90
from rlcompleter import Completer
@@ -2347,7 +2348,7 @@ def main():
2347
2348
print ("The program exited via sys.exit(). Exit status:" , end = ' ' )
2348
2349
print (e )
2349
2350
except BaseException as e :
2350
- traceback .print_exc ( )
2351
+ traceback .print_exception ( e , colorize = _colorize . can_colorize () )
2351
2352
print ("Uncaught exception. Entering post mortem debugging" )
2352
2353
print ("Running 'cont' or 'step' will restart the program" )
2353
2354
pdb .interaction (None , e )
Original file line number Diff line number Diff line change 15
15
from contextlib import ExitStack , redirect_stdout
16
16
from io import StringIO
17
17
from test import support
18
- from test .support import os_helper
18
+ from test .support import force_not_colorized , os_helper
19
19
from test .support .import_helper import import_module
20
20
from test .support .pty_helper import run_pty , FakeInput
21
21
from unittest .mock import patch
@@ -2919,6 +2919,7 @@ def start_pdb():
2919
2919
self .assertNotIn (b'Error' , stdout ,
2920
2920
"Got an error running test script under PDB" )
2921
2921
2922
+ @force_not_colorized
2922
2923
def test_issue16180 (self ):
2923
2924
# A syntax error in the debuggee.
2924
2925
script = "def f: pass\n "
@@ -2932,6 +2933,7 @@ def test_issue16180(self):
2932
2933
'Fail to handle a syntax error in the debuggee.'
2933
2934
.format (expected , stderr ))
2934
2935
2936
+ @force_not_colorized
2935
2937
def test_issue84583 (self ):
2936
2938
# A syntax error from ast.literal_eval should not make pdb exit.
2937
2939
script = "import ast; ast.literal_eval('')\n "
Original file line number Diff line number Diff line change
1
+ Print colorized exception just like built-in traceback in :mod: `pdb `
You can’t perform that action at this time.
0 commit comments