CTK icon indicating copy to clipboard operation
CTK copied to clipboard

Python console stdin is broken

Open auneri opened this issue 8 years ago • 3 comments

I observe this in the nightly build of Slicer, but I suspect the culprit is the recent changes to the Python console.

Any command that inputs stdin causes the cursor to jump to where the command was entered:

input('\nTest:')

A more severe version is when using pdb, which altogether prevents entering debug commands:

1 / 0
import pdb
pdb.pm()

auneri avatar Jul 28 '17 17:07 auneri

Thanks for the report.

I suspect the culprit is the recent changes to the Python console

Most likely.

Would you have time to help address the issue ?

jcfr avatar Jul 28 '17 18:07 jcfr

Did input command work before? Regardless where the cursor position is, whatever you enter as a response to input, it will be interpreted as a command (I think this is not a new behavior).

The refactoring changed interaction between entering commands and printing output. I've fixed an issue of commands incorrectly constructed when string is printed before completing the command (my use case was that background tasks print outputs while I'm typing a command, see #733), but apparently it didn't solve all the issues.

@auneri It would be great if you could propose a fix, I would be happy to test it.

About pdb: the Python console should definitely work well with pdb, but note that there much more powerful visual debuggers (PyCharm, Visual Studio, Eclipse, LiClipse). You can very easily set them up, in any environment and any operating system. You might check them out as well.

lassoan avatar Jul 28 '17 18:07 lassoan

The mentioned pull request seems to at least recover the old behavior.

@lassoan Thanks for the offer, it definitely needs testing to ensure I didn't break anything..

auneri avatar Jul 29 '17 04:07 auneri