Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e96f4e5

Browse files
committed
explicit TypeError when IPCompleter passed to PTCompleter
1 parent 497963c commit e96f4e5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

IPython/terminal/ptutils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from IPython.utils.py3compat import PY3
55

6+
from IPython.core.completer import IPCompleter
67
from prompt_toolkit.completion import Completer, Completion
78
from prompt_toolkit.layout.lexers import Lexer
89
from prompt_toolkit.layout.lexers import PygmentsLexer
@@ -13,8 +14,11 @@
1314
class IPythonPTCompleter(Completer):
1415
"""Adaptor to provide IPython completions to prompt_toolkit"""
1516
def __init__(self, shell):
17+
if isinstance(shell, IPCompleter):
18+
raise TypeError("IPythonPTCompleter expects an InteractiveShell"
19+
" instance in IPython 5.1, not a Completer")
1620
self.shell = shell
17-
21+
1822
@property
1923
def ipy_completer(self):
2024
return self.shell.Completer

0 commit comments

Comments
 (0)