mirror of
https://github.com/python/cpython.git
synced 2025-11-11 14:44:57 +00:00
GH-106734: Disable tab completion in pdb's multiline mode (GH-106735)
This commit is contained in:
parent
b88d9e75f6
commit
391f3e3ca9
2 changed files with 39 additions and 21 deletions
17
Lib/pdb.py
17
Lib/pdb.py
|
|
@ -514,6 +514,22 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||||
if obj is not None:
|
if obj is not None:
|
||||||
self.message(repr(obj))
|
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):
|
def default(self, line):
|
||||||
if line[:1] == '!': line = line[1:].strip()
|
if line[:1] == '!': line = line[1:].strip()
|
||||||
locals = self.curframe_locals
|
locals = self.curframe_locals
|
||||||
|
|
@ -521,6 +537,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||||
try:
|
try:
|
||||||
if (code := codeop.compile_command(line + '\n', '<stdin>', 'single')) is None:
|
if (code := codeop.compile_command(line + '\n', '<stdin>', 'single')) is None:
|
||||||
# Multi-line mode
|
# Multi-line mode
|
||||||
|
with self._disable_tab_completion():
|
||||||
buffer = line
|
buffer = line
|
||||||
continue_prompt = "... "
|
continue_prompt = "... "
|
||||||
while (code := codeop.compile_command(buffer, '<stdin>', 'single')) is None:
|
while (code := codeop.compile_command(buffer, '<stdin>', 'single')) is None:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
Disable tab completion in multiline mode of :mod:`pdb`
|
||||||
Loading…
Add table
Add a link
Reference in a new issue