GH-106734: Disable tab completion in pdb's multiline mode (GH-106735)
This commit is contained in:
parent
b88d9e75f6
commit
391f3e3ca9
17
Lib/pdb.py
17
Lib/pdb.py
@ -514,6 +514,22 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||
if obj is not None:
|
||||
self.message(repr(obj))
|
||||
|
||||
@contextmanager
|
||||
def _disable_tab_completion(self):
|
||||
if self.use_rawinput and self.completekey == 'tab':
|
||||
try:
|
||||
import readline
|
||||
except ImportError:
|
||||
yield
|
||||
return
|
||||
try:
|
||||
readline.parse_and_bind('tab: self-insert')
|
||||
yield
|
||||
finally:
|
||||
readline.parse_and_bind('tab: complete')
|
||||
else:
|
||||
yield
|
||||
|
||||
def default(self, line):
|
||||
if line[:1] == '!': line = line[1:].strip()
|
||||
locals = self.curframe_locals
|
||||
@ -521,6 +537,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||
try:
|
||||
if (code := codeop.compile_command(line + '\n', '<stdin>', 'single')) is None:
|
||||
# Multi-line mode
|
||||
with self._disable_tab_completion():
|
||||
buffer = line
|
||||
continue_prompt = "... "
|
||||
while (code := codeop.compile_command(buffer, '<stdin>', 'single')) is None:
|
||||
|
@ -0,0 +1 @@
|
||||
Disable tab completion in multiline mode of :mod:`pdb`
|
Loading…
x
Reference in New Issue
Block a user