From: Eric S. Raymond Date: Wed, 4 Jun 2014 00:13:33 +0000 (-0400) Subject: Slightly less trivial pylinrt cleanups. X-Git-Tag: 1.9~1 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=62eeeb6b6660e8e75125456503560d4f9e6f049c;p=ssh-installkeys.git Slightly less trivial pylinrt cleanups. Live-test works. --- diff --git a/ssh-installkeys b/ssh-installkeys index b74e1aa..1296be2 100755 --- a/ssh-installkeys +++ b/ssh-installkeys @@ -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