summaryrefslogtreecommitdiff
path: root/Lib/cmd.py
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2003-02-03 11:04:27 +0000
committerMichael W. Hudson <mwh@python.net>2003-02-03 11:04:27 +0000
commitd6545c9341a906e31fa1823e69d242fc102fbff5 (patch)
tree66f79946ae4e5139dc26a2073e711f6b22c0960d /Lib/cmd.py
parent47fa2413fef1d53565dca37dc6e7880deda13fb8 (diff)
downloadcpython-d6545c9341a906e31fa1823e69d242fc102fbff5.tar.gz
Fix bug
[ 676342 ] after using pdb readline does not work correctly using Michael Stone's patch so the completer functionality of cmd is only setup between preloop and postloop.
Diffstat (limited to 'Lib/cmd.py')
-rw-r--r--Lib/cmd.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/Lib/cmd.py b/Lib/cmd.py
index f0637ed500..592990310b 100644
--- a/Lib/cmd.py
+++ b/Lib/cmd.py
@@ -86,13 +86,7 @@ class Cmd:
"""
self.cmdqueue = []
- if completekey:
- try:
- import readline
- readline.set_completer(self.complete)
- readline.parse_and_bind(completekey+": complete")
- except ImportError:
- pass
+ self.completekey = completekey
def cmdloop(self, intro=None):
"""Repeatedly issue a prompt, accept input, parse an initial prefix
@@ -142,14 +136,26 @@ class Cmd:
def preloop(self):
"""Hook method executed once when the cmdloop() method is called."""
- pass
+ if self.completekey:
+ try:
+ import readline
+ self.old_completer = readline.get_completer()
+ readline.set_completer(self.complete)
+ readline.parse_and_bind(self.completekey+": complete")
+ except ImportError:
+ pass
def postloop(self):
"""Hook method executed once when the cmdloop() method is about to
return.
"""
- pass
+ if self.completekey:
+ try:
+ import readline
+ readline.set_completer(self.old_completer)
+ except ImportError:
+ pass
def parseline(self, line):
line = line.strip()