Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
import _colorize

from contextlib import contextmanager
from rlcompleter import Completer
from types import CodeType


Expand Down Expand Up @@ -332,6 +331,15 @@ def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None,
readline.set_completer_delims(' \t\n`@#%^&*()=+[{]}\\|;:\'",<>?')
except ImportError:
pass

# GH-138860
# We need to lazy-import rlcompleter to avoid deadlock
# We cannot import it during self.complete* methods because importing
# rlcompleter for the first time will overwrite readline's completer
# So we import it here and save the Completer class
from rlcompleter import Completer
self.RlCompleter = Completer

self.allow_kbdint = False
self.nosigint = nosigint
# Consider these characters as part of the command so when the users type
Expand Down Expand Up @@ -986,10 +994,9 @@ def completedefault(self, text, line, begidx, endidx):
conv_vars = self.curframe.f_globals.get('__pdb_convenience_variables', {})
return [f"${name}" for name in conv_vars if name.startswith(text[1:])]

# Use rlcompleter to do the completion
state = 0
matches = []
completer = Completer(self.curframe.f_globals | self.curframe_locals)
completer = self.RlCompleter(self.curframe.f_globals | self.curframe.f_locals)
while (match := completer.complete(text, state)) is not None:
matches.append(match)
state += 1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Lazy import :mod:`rlcompleter` in :mod:`pdb` to avoid deadlock in subprocess.
Loading