Skip to content

Commit 897efaf

Browse files
committed
Print the same message in traceback when str failed as CPython
1 parent 1a7cc3e commit 897efaf

File tree

1 file changed

+4
-1
lines changed
  • graalpython/lib-graalpython

1 file changed

+4
-1
lines changed

graalpython/lib-graalpython/sys.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ def simple_print_traceback(e):
184184
def __print_traceback__(typ, value, tb):
185185
try:
186186
import traceback
187-
traceback.print_exception(typ, value, tb)
187+
lines = traceback.format_exception(typ, value, tb)
188+
lines[-1] = lines[-1].replace(f'<unprintable {typ.__name__} object>', f'<exception str() failed>')
189+
for line in lines:
190+
print(line, file=stderr, end="")
188191
except BaseException as exc:
189192
print("Error in sys.excepthook:\n", file=stderr)
190193
simple_print_traceback(exc)

0 commit comments

Comments
 (0)