Title: Readline/tab completion fails when using the cmd module
Type: crash Severity: normal
Components: Library Versions: Jython 2.7
Milestone: Jython 2.7.0
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: darjus Nosy List: brunteman, darjus, zyasoft
Priority: Keywords:

Created on 2015-09-14.14:12:51 by brunteman, last changed 2015-10-07.04:56:29 by darjus.

msg10260 (view) Author: Mattias Nilsson (brunteman) Date: 2015-09-14.14:12:50
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 "", line 251, in <module>
  File "/home/user/devtools/jython2.7.0/Lib/", line 130, in cmdloop
    line = raw_input(self.prompt)
  File "/home/user/devtools/jython2.7.0/Lib/", line 130, in cmdloop
    line = raw_input(self.prompt)
  File "/home/user/devtools/jython2.7.0/Lib/", 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):

if __name__ == '__main__':
msg10305 (view) Author: Darjus Loktevic (darjus) Date: 2015-10-02.01:32:57
Looks like when we enter pdb, we're not considering it to be interactive mode. Related to
msg10306 (view) Author: Darjus Loktevic (darjus) Date: 2015-10-02.03:56:42
The issue is now fixed in the latest commit.
msg10307 (view) Author: Darjus Loktevic (darjus) Date: 2015-10-07.04:56:28
Closing, this will be released with 2.7.1
Date User Action Args
2015-10-07 04:56:29darjussetstatus: open -> closed
assignee: zyasoft -> darjus
resolution: fixed
messages: + msg10307
milestone: Jython 2.7.0
2015-10-02 03:56:42darjussetmessages: + msg10306
2015-10-02 01:32:57darjussetnosy: + darjus
messages: + msg10305
2015-09-17 20:32:37zyasoftsetassignee: zyasoft
nosy: + zyasoft
2015-09-14 14:12:51bruntemancreate