Message10260

Author brunteman
Recipients brunteman
Date 2015-09-14.14:12:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1442239971.55.0.350604399649.issue2398@psf.upfronthosting.co.za>
In-reply-to
Content
When creating an interactive tool using jython 2.7.0 and the cmd module, tab completion will give this error:

Traceback (most recent call last):
  File "cli.py", line 251, in <module>
    Cli().cmdloop()
  File "/home/user/devtools/jython2.7.0/Lib/cmd.py", line 130, in cmdloop
    line = raw_input(self.prompt)
  File "/home/user/devtools/jython2.7.0/Lib/cmd.py", line 130, in cmdloop
    line = raw_input(self.prompt)
  File "/home/user/devtools/jython2.7.0/Lib/readline.py", line 120, in complete_handler
    if _reader.prompt == sys.ps2 and (not delimited or delimited.isspace()):
AttributeError: '<reflected field public org.python.core.PyObject o' object has no attribute 'ps2'


I worked around the problem by changing the line to:
if _reader.prompt == getattr(sys, 'ps2', None) and (not delimited or delimited.isspace()):

But I suppose that it should in fact be fixed elsewhere. sys.ps2 is set in interactive mode, but I am not sure if an cmd application counts as that.

Recreating the problem was easy, Just run this code and hit TAB:

import cmd

class HelloWorld(cmd.Cmd):
   pass

if __name__ == '__main__':
    HelloWorld().cmdloop()
History
Date User Action Args
2015-09-14 14:12:51bruntemansetrecipients: + brunteman
2015-09-14 14:12:51bruntemansetmessageid: <1442239971.55.0.350604399649.issue2398@psf.upfronthosting.co.za>
2015-09-14 14:12:51bruntemanlinkissue2398 messages
2015-09-14 14:12:50bruntemancreate