From 30e3d9f89e44c46310642680319333f0065fae78 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Tue, 30 Jun 2020 13:13:10 -0700 Subject: [PATCH] catch unrecoverable error Switch to print_exception --- IPython/terminal/ptutils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/IPython/terminal/ptutils.py b/IPython/terminal/ptutils.py index ed7ad45eb45..3cf3c11215b 100644 --- a/IPython/terminal/ptutils.py +++ b/IPython/terminal/ptutils.py @@ -112,8 +112,11 @@ def get_completions(self, document, complete_event): try: yield from self._get_completions(body, offset, cursor_position, self.ipy_completer) except Exception as e: - from traceback import print_tb - print_tb(e) + try: + exc_type, exc_value, exc_tb = sys.exc_info() + traceback.print_exception(exc_type, exc_value, exc_tb) + except AttributeError: + print('Unrecoverable Error in completions') @staticmethod def _get_completions(body, offset, cursor_position, ipyc):