Search code examples
pythonpython-2.7pxssh

TypeError: __init__() got an unexpected keyword argument 'options'


I am getting an error from a python script. The error is shown below. In the source code furthur down, I have an snippet of the python script from session.py and ssh_session.py from around the lines in quesiton. Based on the error, it seems that the parameter options was given to a class denoted by super, where that class doesn't know the parameter options. The screwy part is that although this is my first time working with this set of scripts, I know that other folks use this set of scripts all the time succesfully. So I started thinking that maybe I have a version problem relative to a python module. Can anyone shed light on the nature of an error where __init__ would cry foul on an unexpected keyword argument, when it seems to work for everyone else? If it is a module issue, how would I actually know when or in which version the argument came into existence, or was removed?

2017-03-17 16:23:36,303-07 ERROR        -   File "/home/rmaes/.local/lib/python2.7/site-packages/ctf/ssh_session.py", line 92, in __init__
2017-03-17 16:23:36,303-07 ERROR        -   interactOnFailure=interactOnFailure, verbose=verbose, logLevel=logLevel)
2017-03-17 16:23:36,303-07 ERROR        -   File "/home/rmaes/.local/lib/python2.7/site-packages/ctf/session.py", line 376, in __init__
2017-03-17 16:23:36,303-07 ERROR        -   env=self.env)
2017-03-17 16:23:36,303-07 ERROR        -   TypeError: __init__() got an unexpected keyword argument 'options'
2017-03-17 16:23:36,303-07 ERROR        -   End traceback.
2017-03-17 16:23:36,304-07 INFO         - END ANCILLARY "_testRunSuite"
2017-03-17 16:23:36,304-07 INFO         - Exception forces exit because exit-on-error is True.

ssh_session line 92

super (Ssh, self).__init__(timeout=timeout, maxread=maxread,
       searchwindowsize=searchwindowsize, logfile=logfile, cwd=cwd, env=env,
       ignore_sighup=ignore_sighup, echo=echo, options=options,
       encoding=encoding, codec_errors=codec_errors,
       interactOnFailure=interactOnFailure, verbose=verbose, logLevel=logLevel)


def login (self, host, username, password='', terminal_type='ansi',
           original_prompt=r"[#$]", login_timeout=10, port=22,
           auto_prompt_reset=True, ssh_key=None, quiet=True,
           sync_multiplier=1, check_local_ip=True):

session.py Line 375-376

 # Instantiate the pxssh sub-class
        super (PxsshSession, self).__init__(timeout=self.timeout,
                                            maxread=self.maxread,
                                            searchwindowsize=self.searchwindowsize,
                                            logfile=self.logfile,
                                            options=self.options,
                                            ignore_sighup=self.ignore_sighup,
                                            cwd=self.cwd,
                                            env=self.env)

Solution

  • So it appears that a change introduce in pexpect 4.0.1 resolves the issue that I am seeing, however, I am still not able to determine what that change was. GITHUB has a label created for 4.0.1, but no official release and no release notes. The official release notes for 4.1.0 don't seem to allude to anything having to do with "options" being added or removed as parameter. But clearly, anything further than pexpect 4.0.1 clears this issue.