[Python-checkins] python/dist/src/Lib cmd.py,1.37,1.38
mwh at users.sourceforge.net
mwh at users.sourceforge.net
Thu Jul 1 10:52:13 EDT 2004
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7724
Modified Files:
cmd.py
Log Message:
Fix
[ 924301 ] A leak case with cmd.py & readline & exception
by ensuring that the readline completion function is always reset
even in the case of an exception being raised. As a bonus, this
makes the documentation for pre & postloop accurate again.
Index: cmd.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/cmd.py,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** cmd.py 22 Oct 2003 14:38:54 -0000 1.37
--- cmd.py 1 Jul 2004 14:52:10 -0000 1.38
***************
*** 108,137 ****
self.preloop()
! if intro is not None:
! self.intro = intro
! if self.intro:
! self.stdout.write(str(self.intro)+"\n")
! stop = None
! while not stop:
! if self.cmdqueue:
! line = self.cmdqueue.pop(0)
! else:
! if self.use_rawinput:
! try:
! line = raw_input(self.prompt)
! except EOFError:
! line = 'EOF'
else:
! self.stdout.write(self.prompt)
! self.stdout.flush()
! line = self.stdin.readline()
! if not len(line):
! line = 'EOF'
else:
! line = line[:-1] # chop \n
! line = self.precmd(line)
! stop = self.onecmd(line)
! stop = self.postcmd(stop, line)
! self.postloop()
def precmd(self, line):
--- 108,154 ----
self.preloop()
! if self.use_rawinput and 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
! try:
! if intro is not None:
! self.intro = intro
! if self.intro:
! self.stdout.write(str(self.intro)+"\n")
! stop = None
! while not stop:
! if self.cmdqueue:
! line = self.cmdqueue.pop(0)
else:
! if self.use_rawinput:
! try:
! line = raw_input(self.prompt)
! except EOFError:
! line = 'EOF'
else:
! self.stdout.write(self.prompt)
! self.stdout.flush()
! line = self.stdin.readline()
! if not len(line):
! line = 'EOF'
! else:
! line = line[:-1] # chop \n
! line = self.precmd(line)
! stop = self.onecmd(line)
! stop = self.postcmd(stop, line)
! self.postloop()
! finally:
! if self.use_rawinput and self.completekey:
! try:
! import readline
! readline.set_completer(self.old_completer)
! except ImportError:
! pass
!
def precmd(self, line):
***************
*** 148,159 ****
def preloop(self):
"""Hook method executed once when the cmdloop() method is called."""
! 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):
--- 165,169 ----
def preloop(self):
"""Hook method executed once when the cmdloop() method is called."""
! pass
def postloop(self):
***************
*** 162,172 ****
"""
! if self.completekey:
! try:
! import readline
! readline.set_completer(self.old_completer)
! except ImportError:
! pass
!
def parseline(self, line):
"""Parse the line into a command name and a string containing
--- 172,177 ----
"""
! pass
!
def parseline(self, line):
"""Parse the line into a command name and a string containing
More information about the Python-checkins
mailing list