Repository navigation
Improve Python console: Fix compound mode, Ctrl+C handling and auto-indent - #678
Conversation
joern274
left a comment
There was a problem hiding this comment.
Thank you very much for providing this PR to improve the Python console. I haven't done a thorough review yet, but I can already see some valuable contributions, like using codeop to check whether a statement is complete instead of calling the parser directly.
Unfortunately, the code you worked on has changed in the meantime to fix other problems (3418bd2), so your PR no longer merges without conflicts. Please rebase it onto the current master.
You might also want to test whether some of the problems you were targeting are already gone. For example, I added the [Esc] key to leave compound mode, since users complained about getting trapped in it, and I removed some causes of getting trapped by accident, such as pressing [Enter] twice.
Also note that PR #672 changes interpretCommand() and checkCompleteStatement() as well, so whichever of the two is merged later will need another small rebase.
I look forward to reviewing and merging your PR once it is rebased.
8163aa7 to
cad7426
Compare
|
I did the rebase. I kept my approach to the interpretCommand restructure, because it is more readable and makes auto indent possible, and adopted two improvements from HEAD. I kept the codeop base implementation. |
|
Note that this PR partially addresses #672: PyErr_Clear is resolved by the rewrite using codeop. |
joern274
left a comment
There was a problem hiding this comment.
Will merge useful PR now and fix minor weaknesses afterwards, namely:
- By now we have already a hotkey to escape compound mode (Esc), we don't need two
- Converting tabs to 4 spaces must be consistent including history entries and paste
- The history index is reset when input is discarded.
Fix minor quirks after PR #678
Problem
Changes
Behavior is modeled after the standard Python shell
:codeop.compile_commandinstead of removedPyParser/Py_CompileStringExFlagsAPI. This can distinguish between incomplete, complete and syntax error