[Python-checkins] CVS: python/dist/src/Lib cmd.py,1.22,1.23

Guido van Rossum gvanrossum@users.sourceforge.net
Thu, 22 Mar 2001 13:59:22 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv9037

Modified Files:
	cmd.py 
Log Message:
This is SF patch #405952, by Anthony Baxter:
cmd.py uses raw_input(); eats SIGCLD:

  I discovered a rather nasty side effect of the standard cmd.py
  library today. If it's sitting inside raw_input(), any SIGCLDs that
  get sent to your application get silently eaten and ignored. I'm
  assuming that this is something that readline is thoughtfully doing
  for me.

  This patch adds an instance attr that allows the user to select to
  not use raw_input(), but instead use sys.stdin.readline()

[Changed slightly to catch EOFError only for raw_input().]


Index: cmd.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/cmd.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -r1.22 -r1.23
*** cmd.py	2001/02/09 04:52:11	1.22
--- cmd.py	2001/03/22 21:59:20	1.23
***************
*** 36,40 ****
  """
  
! import string
  
  __all__ = ["Cmd"]
--- 36,40 ----
  """
  
! import string, sys
  
  __all__ = ["Cmd"]
***************
*** 55,58 ****
--- 55,59 ----
      undoc_header = "Undocumented commands:"
      nohelp = "*** No help on %s"
+     use_rawinput = 1
  
      def __init__(self): pass
***************
*** 70,77 ****
                  del self.cmdqueue[0]
              else:
!                 try:
!                     line = raw_input(self.prompt)
!                 except EOFError:
!                     line = 'EOF'
              line = self.precmd(line)
              stop = self.onecmd(line)
--- 71,86 ----
                  del self.cmdqueue[0]
              else:
!                 if self.use_rawinput:
!                     try:
!                         line = raw_input(self.prompt)
!                     except EOFError:
!                         line = 'EOF'
!                 else:
!                     sys.stdout.write(self.prompt)
!                     line = sys.stdin.readline()
!                     if not len(line):
!                         line = 'EOF'
!                     else:
!                         line = line[:-1] # chop \n
              line = self.precmd(line)
              stop = self.onecmd(line)