trouble with cmd.Cmd and prompting
cs at zip.com.au
Wed Jan 18 05:49:31 EST 2017
On 04Jan2017 12:20, Cameron Simpson <cs at zip.com.au> wrote:
>I will try to get a minimal example others can run.
Well I've made some time for this, and it seems to be an interaction with my
python3, the "input" builtin, and readline. Cmd.cmdloop behaves fine if I turn
off the .raw_input attribute, and I can reproduce the issue without the cmd
line = input("F> ")
line = input("G> ")
Results on a terminal:
[~]fleet*2> python3 foo.py
That "%" is an artifact of no final newline after the "G> ".
If I comment out the import of readline it looks like this:
[~]fleet*> python3 foo.py
as one would expect. Ignoring my shell prompts, the contents of a typescript
Those "^M"s are carriage returns. I kind of suspect the second "F> " is
readline doing some kind of redraw. I am baffled by the lack of initial "G> "
prompt; that "G> " above appears to be the secondary issue, after I've pressed
return for the "b" line.
This is on a Mac, so I've no strace command to hand. I've also got all manner
of potential special stuff (readline library from MacPorts, etc). I'll keep
stripping stuff back...
Cameron Simpson <cs at zip.com.au>
More information about the Python-list