Repository navigation
Fixes SyntaxError (U+2029) after pasting a multi-line script - #672
Conversation
7cbaf94 to
c9323a0
Compare
joern274
left a comment
There was a problem hiding this comment.
Thank you for PR #672, which covered three bugs that existed at the time the PR was created: line breaks arriving as U+2029, which caused misleading error messages; a missing clear after a failed parse; and a memory leak caused by not releasing the parse result. That was good work! We stumbled over the same problems resolving unrelated Python console issues (see changelog). The bugs mentioned above are resolved by now. Your PR confirms that we came to the same diagnosis. Another improvement came from an external contributor introducing codeop to evaluate the console input. Compound multi-line input like for i in range(10):\n print(i) is now parsed and executed without a problem.
What has not been merged from PR #672 so far is the feature to paste several independent statements at once. I will merge it now. However, there is one caveat: Once user start to paste any number of independent statements at once, they will for sure complain about problems editing the pasted lines, poor navigation, and the lack of syntax highlighting.
What I recommend : The documentation should point out that pasting several independent statements into the Python console is not the recommended strategy. They should paste it into an unnamed Python editor tab instead.
Resolves #662
Pasted lines reach the console separated by
U+2029instead of\n, so a pasted snippet never parsed. On top of that, a failed parse was never cleared, which made every later parse fail as well, so the console stayed at...for good, even for a plainforloop.Now line breaks are converted before parsing, and a failed parse no longer breaks the next one.
...for i in [1,2,3]:/print(i)...1 2 3a = = 1...SyntaxError, console keeps working