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

Skip to content

Commit 0f79628

Browse files
committed
Fix error tab completing in the debugger
I think I broke this in 5.2. Closes gh-10222
1 parent 8869e7f commit 0f79628

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

IPython/terminal/debugger.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ def pt_init(self):
2020
def get_prompt_tokens(cli):
2121
return [(Token.Prompt, self.prompt)]
2222

23+
def patch_stdout(**kwargs):
24+
return self.pt_cli.patch_stdout_context(**kwargs)
25+
2326
if self._ptcomp is None:
2427
compl = IPCompleter(shell=self.shell,
2528
namespace={},
2629
global_namespace={},
2730
parent=self.shell,
2831
)
29-
self._ptcomp = IPythonPTCompleter(compl)
32+
self._ptcomp = IPythonPTCompleter(compl, patch_stdout=patch_stdout)
3033

3134
self._pt_app = create_prompt_application(
3235
editing_mode=getattr(EditingMode, self.shell.editing_mode.upper()),

IPython/terminal/interactiveshell.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,15 @@ def prompt():
233233

234234
editing_mode = getattr(EditingMode, self.editing_mode.upper())
235235

236+
def patch_stdout(**kwargs):
237+
return self.pt_cli.patch_stdout_context(**kwargs)
238+
236239
self._pt_app = create_prompt_application(
237240
editing_mode=editing_mode,
238241
key_bindings_registry=kbmanager.registry,
239242
history=history,
240-
completer=IPythonPTCompleter(shell=self),
243+
completer=IPythonPTCompleter(shell=self,
244+
patch_stdout=patch_stdout),
241245
enable_history_search=True,
242246
style=style,
243247
mouse_support=self.mouse_support,

IPython/terminal/ptutils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020

2121
class IPythonPTCompleter(Completer):
2222
"""Adaptor to provide IPython completions to prompt_toolkit"""
23-
def __init__(self, ipy_completer=None, shell=None):
23+
def __init__(self, ipy_completer=None, shell=None, patch_stdout=None):
2424
if shell is None and ipy_completer is None:
2525
raise TypeError("Please pass shell=an InteractiveShell instance.")
2626
self._ipy_completer = ipy_completer
2727
self.shell = shell
28+
if patch_stdout is None:
29+
raise TypeError("Please pass patch_stdout")
30+
self.patch_stdout = patch_stdout
2831

2932
@property
3033
def ipy_completer(self):
@@ -40,7 +43,7 @@ def get_completions(self, document, complete_event):
4043
# Some bits of our completion system may print stuff (e.g. if a module
4144
# is imported). This context manager ensures that doesn't interfere with
4245
# the prompt.
43-
with self.shell.pt_cli.patch_stdout_context():
46+
with self.patch_stdout():
4447
used, matches = self.ipy_completer.complete(
4548
line_buffer=document.current_line,
4649
cursor_pos=document.cursor_position_col

0 commit comments

Comments
 (0)