From d58a6ec24c39c9f5b500a348f60eaf598dc52f35 2017-09-13 19:18:22 From: Matthias Bussonnier Date: 2017-09-13 19:18:22 Subject: [PATCH] Let keyboard interrupt stop custom dispatch of completer. See #10733, interruption during custom completer can crash the kernel. Technically we should likely even protect normal completion (like jedi taking a while), but let's get something that fix an actual bug. This can lead to some inconsistencies in the frontend, as you interrupt the kernel in Command mode, and interrupting the current custom completer will lead to normal completion being (still) returned and the completer poping up in command mode. It's not optimal but at least we do not loose user state. --- diff --git a/IPython/core/completer.py b/IPython/core/completer.py index 18905b1..1f5eecd 100644 --- a/IPython/core/completer.py +++ b/IPython/core/completer.py @@ -1715,6 +1715,12 @@ class IPCompleter(Completer): return [r for r in res if r.lower().startswith(text_low)] except TryNext: pass + except KeyboardInterrupt: + """ + If custom completer take too long, + let keyboard interrupt abort and return nothing. + """ + break return None