File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -505,6 +505,10 @@ def abbr_meta(text: str) -> str:
505505 display = f"[{ k_repr } ]" ,
506506 display_meta = abbr_meta (self ._do_repr (result [k ])),
507507 )
508+ except KeyError :
509+ # `result[k]` lookup failed. Trying to complete
510+ # broken object.
511+ pass
508512 except ReprFailedError :
509513 pass
510514
@@ -521,6 +525,10 @@ def abbr_meta(text: str) -> str:
521525 display = f"[{ k_repr } ]" ,
522526 display_meta = abbr_meta (self ._do_repr (result [k ])),
523527 )
528+ except KeyError :
529+ # `result[k]` lookup failed. Trying to complete
530+ # broken object.
531+ pass
524532 except ReprFailedError :
525533 pass
526534
Original file line number Diff line number Diff line change @@ -135,6 +135,12 @@ def run(self) -> None:
135135 text = self .read ()
136136 except EOFError :
137137 return
138+ except BaseException as e :
139+ # Something went wrong while reading input.
140+ # (E.g., a bug in the completer that propagates. Don't
141+ # crash the REPL.)
142+ traceback .print_exc ()
143+ continue
138144
139145 # Run it; display the result (or errors if applicable).
140146 self .run_and_show_expression (text )
@@ -192,6 +198,12 @@ async def run_async(self) -> None:
192198 text = await loop .run_in_executor (None , self .read )
193199 except EOFError :
194200 return
201+ except BaseException :
202+ # Something went wrong while reading input.
203+ # (E.g., a bug in the completer that propagates. Don't
204+ # crash the REPL.)
205+ traceback .print_exc ()
206+ continue
195207
196208 # Eval.
197209 await self .run_and_show_expression_async (text )
You can’t perform that action at this time.
0 commit comments