MCPcopy Index your code
hub / github.com/python/cpython / rlcompleter

Method rlcompleter

Lib/pdb.py:1129–1151  ·  view source on GitHub ↗

Return the `Completer` class from `rlcompleter`, while avoiding the side effects of changing the completer from `import rlcompleter`. This is a compromise between GH-138860 and GH-139289. If GH-139289 is fixed, then we don't need this and we can just `import rlcompleter` in

(self)

Source from the content-addressed store, hash-verified

1127
1128 @property
1129 def rlcompleter(self):
1130 """Return the `Completer` class from `rlcompleter`, while avoiding the
1131 side effects of changing the completer from `import rlcompleter`.
1132
1133 This is a compromise between GH-138860 and GH-139289. If GH-139289 is
1134 fixed, then we don't need this and we can just `import rlcompleter` in
1135 `Pdb.__init__`.
1136 """
1137 if not hasattr(self, "_rlcompleter"):
1138 try:
1139 import readline
1140 except ImportError:
1141 # readline is not available, just get the Completer
1142 from rlcompleter import Completer
1143 self._rlcompleter = Completer
1144 else:
1145 # importing rlcompleter could have side effect of changing
1146 # the current completer, we need to restore it
1147 prev_completer = readline.get_completer()
1148 from rlcompleter import Completer
1149 self._rlcompleter = Completer
1150 readline.set_completer(prev_completer)
1151 return self._rlcompleter
1152
1153 def completenames(self, text, line, begidx, endidx):
1154 # Overwrite completenames() of cmd so for the command completion,

Callers 2

completedefaultMethod · 0.95
_enable_rlcompleterMethod · 0.95

Calls 2

get_completerMethod · 0.80
set_completerMethod · 0.80

Tested by

no test coverage detected