]> thyrsus.com Git - ssh-installkeys.git/commitdiff
Slightly less trivial pylinrt cleanups.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 4 Jun 2014 00:13:33 +0000 (20:13 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 4 Jun 2014 00:13:33 +0000 (20:13 -0400)
Live-test works.

ssh-installkeys

index b74e1aaf7af599bc058def425b7713d394c99b68..1296be29dfa2a45775cd83e22aafc9e93cdf42d5 100755 (executable)
@@ -121,6 +121,7 @@ class ExceptionPexpect(Exception):
 
     def __init__(self, value):
 
+        Exception.__init__(self)
         self.value = value
 
     def __str__(self):
@@ -288,7 +289,7 @@ class spawn(object):
     """This is the main class interface for Pexpect. Use this class to start
     and control child applications. """
 
-    def __init__(self, command, args=[], timeout=30, maxread=2000, searchwindowsize=None, logfile=None, cwd=None, env=None):
+    def __init__(self, command, args=None, timeout=30, maxread=2000, searchwindowsize=None, logfile=None, cwd=None, env=None):
 
         """This is the constructor. The command parameter may be a string that
         includes a command and any arguments to the command. For example::
@@ -504,7 +505,7 @@ class spawn(object):
         s.append('delayafterterminate: ' + str(self.delayafterterminate))
         return '\n'.join(s)
 
-    def _spawn(self, command, args=[]):
+    def _spawn(self, command, args=None):
 
         """This starts the given command in a child process. This does all the
         fork/exec type of stuff for a pty. This is called by __init__. If args
@@ -524,6 +525,9 @@ class spawn(object):
         if type(command) == type(0):
             raise ExceptionPexpect('Command is an int type. If this is a file descriptor then maybe you want to use fdpexpect.fdspawn which takes an existing file descriptor instead of a command string.')
 
+        # Avoids dangerous default
+        if args is None:
+            args = []
         if type(args) != type([]):
             raise TypeError('The argument, args, must be a list.')
 
@@ -1636,6 +1640,7 @@ class searcher_string(object):
                 self.timeout_index = n
                 continue
             self._strings.append((n, s))
+        self.start = self.end = self.match = None
 
     def __str__(self):
 
@@ -1725,6 +1730,7 @@ class searcher_re(object):
         self.eof_index = -1
         self.timeout_index = -1
         self._searches = []
+        self.start = self.end = self.match = None
         for n, s in zip(range(len(patterns)), patterns):
             if s is EOF:
                 self.eof_index = n