|
17 | 17 | from prompt_toolkit.enums import EditingMode |
18 | 18 | from prompt_toolkit.formatted_text import PygmentsTokens |
19 | 19 |
|
| 20 | +from prompt_toolkit import __version__ as ptk_version |
| 21 | +PTK3 = ptk_version.startswith('3.') |
| 22 | + |
20 | 23 |
|
21 | 24 | class TerminalPdb(Pdb): |
22 | 25 | """Standalone IPython debugger.""" |
@@ -49,20 +52,23 @@ def get_prompt_tokens(): |
49 | 52 | & ~cursor_in_leading_ws |
50 | 53 | ))(display_completions_like_readline) |
51 | 54 |
|
52 | | - self.pt_app = PromptSession( |
53 | | - message=(lambda: PygmentsTokens(get_prompt_tokens())), |
54 | | - editing_mode=getattr(EditingMode, self.shell.editing_mode.upper()), |
55 | | - key_bindings=kb, |
56 | | - history=self.shell.debugger_history, |
57 | | - completer=self._ptcomp, |
58 | | - enable_history_search=True, |
59 | | - mouse_support=self.shell.mouse_support, |
60 | | - complete_style=self.shell.pt_complete_style, |
61 | | - style=self.shell.style, |
62 | | - inputhook=self.shell.inputhook, |
63 | | - color_depth=self.shell.color_depth, |
| 55 | + options = dict( |
| 56 | + message=(lambda: PygmentsTokens(get_prompt_tokens())), |
| 57 | + editing_mode=getattr(EditingMode, self.shell.editing_mode.upper()), |
| 58 | + key_bindings=kb, |
| 59 | + history=self.shell.debugger_history, |
| 60 | + completer=self._ptcomp, |
| 61 | + enable_history_search=True, |
| 62 | + mouse_support=self.shell.mouse_support, |
| 63 | + complete_style=self.shell.pt_complete_style, |
| 64 | + style=self.shell.style, |
| 65 | + color_depth=self.shell.color_depth, |
64 | 66 | ) |
65 | 67 |
|
| 68 | + if not PTK3: |
| 69 | + options['inputhook'] = self.inputhook |
| 70 | + self.pt_app = PromptSession(**options) |
| 71 | + |
66 | 72 | def cmdloop(self, intro=None): |
67 | 73 | """Repeatedly issue a prompt, accept input, parse an initial prefix |
68 | 74 | off the received input, and dispatch to action methods, passing them |
|
0 commit comments