Skip to content

Commit

Permalink
Let keyboard interrupt stop custom dispatch of completer.
Browse files Browse the repository at this point in the history
See ipython#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.
  • Loading branch information
Carreau committed Sep 13, 2017
1 parent 7ebd20f commit 230ce65
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion IPython/core/completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,14 @@ def dispatch_custom_completer(self, text):
try_magic,
self.custom_completers.flat_matches(self.text_until_cursor)):
try:
res = c(event)
try:
res = c(event)
except KeyboardInterrupt:
"""
If custom completer take too long,
let keyboard interrupt abort and return nothing.
"""
break
if res:
# first, try case sensitive match
withcase = [r for r in res if r.startswith(text)]
Expand Down

0 comments on commit 230ce65

Please sign in to comment.