Skip to content

Commit 3ed381f

Browse files
committed
Improve traceback display
This matches runtime better, e.g. we also show exception notes
1 parent ef7e8a6 commit 3ed381f

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

mypy/errors.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,12 +1390,9 @@ def report_internal_error(
13901390
file=stderr,
13911391
)
13921392
else:
1393-
tb = traceback.extract_stack()[:-2]
1394-
tb2 = traceback.extract_tb(sys.exc_info()[2])
1395-
print("Traceback (most recent call last):")
1396-
for s in traceback.format_list(tb + tb2):
1397-
print(s.rstrip("\n"))
1398-
print(f"{type(err).__name__}: {err}", file=stdout)
1393+
tberr = traceback.TracebackException.from_exception(err)
1394+
tberr.stack[:0] = traceback.extract_stack()[:-2]
1395+
print("".join(tberr.format()), file=stdout)
13991396
print(f"{prefix}note: use --pdb to drop into pdb", file=stderr)
14001397

14011398
# Exit. The caller has nothing more to say.

0 commit comments

Comments
 (0)