Skip to content

Commit 7ea2e5b

Browse files
Handle exceptions raised when repr() is called.
1 parent 9a3d6c1 commit 7ea2e5b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ptpython/repl.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,13 @@ def show_result(self, result: object) -> None:
270270
out_prompt = to_formatted_text(self.get_output_prompt())
271271

272272
# If the repr is valid Python code, use the Pygments lexer.
273-
result_repr = repr(result)
273+
try:
274+
result_repr = repr(result)
275+
except BaseException as e:
276+
# Calling repr failed.
277+
self._handle_exception(e)
278+
return
279+
274280
try:
275281
compile(result_repr, "", "eval")
276282
except SyntaxError:

0 commit comments

Comments
 (0)