Skip to content

Add prompt toolkit 3 compatibility to ipdb - #11979

Merged
Carreau merged 1 commit into
ipython:masterfrom
Carreau:ipdb-ptk
Dec 1, 2019
Merged

Carreau merged 1 commit into
ipython:masterfrom
Carreau:ipdb-ptk

Conversation

@Carreau

@Carreau Carreau commented Nov 30, 2019

Copy link
Copy Markdown
Member

closes #11962
closes #11975

@JBKahn

JBKahn commented Dec 4, 2019 •

Copy link
Copy Markdown
Contributor

@Carreau I'm not sure I understand the fix put in place enough to understand if this is an issue with ipdb or iPython or my system

In this code you modified:

class TerminalPdb(Pdb):
"""Standalone IPython debugger."""
def __init__(self, *args, **kwargs):
Pdb.__init__(self, *args, **kwargs)
self._ptcomp = None
self.pt_init()
def pt_init(self):
def get_prompt_tokens():
return [(Token.Prompt, self.prompt)]
if self._ptcomp is None:
compl = IPCompleter(shell=self.shell,
namespace={},
global_namespace={},
parent=self.shell,
)
self._ptcomp = IPythonPTCompleter(compl)
kb = KeyBindings()
supports_suspend = Condition(lambda: hasattr(signal, 'SIGTSTP'))
kb.add('c-z', filter=supports_suspend)(suspend_to_bg)
if self.shell.display_completions == 'readlinelike':
kb.add('tab', filter=(has_focus(DEFAULT_BUFFER)
& ~has_selection
& vi_insert_mode | emacs_insert_mode
& ~cursor_in_leading_ws
))(display_completions_like_readline)
options = dict(
message=(lambda: PygmentsTokens(get_prompt_tokens())),
editing_mode=getattr(EditingMode, self.shell.editing_mode.upper()),
key_bindings=kb,
history=self.shell.debugger_history,
completer=self._ptcomp,
enable_history_search=True,
mouse_support=self.shell.mouse_support,
complete_style=self.shell.pt_complete_style,
style=self.shell.style,
color_depth=self.shell.color_depth,
)
if not PTK3:
options['inputhook'] = self.inputhook
self.pt_app = PromptSession(**options)

It accesses self.inputhook but Pdb and TerminalPdb don't seem to have an inputhook. At least I get an AttributeError trying to access self.inputhook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incompatibility with prompt_toolkit v3.0.0 TypeError: __init__() got an unexpected keyword argument 'inputhook'

2 participants