-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-119517: Fix several issues when pasting lot of text in the REPL #120234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* Restore signal handlers for SIGINT and SIGSTOP (Ctrl-C and Ctrl-Z) * Ensure that signals are processed as soon as possible by making reads more efficient. * Protect against invalid state in internal REPL functions when interrumpted. * Do not show extraneous newlines above the scroll buffer when pasting text in the REPL Signed-off-by: Pablo Galindo <[email protected]>
@treyhunner can you check this PR? (Both the issues and the performance of pasting) |
Signed-off-by: Pablo Galindo <[email protected]>
This is certainly an improvement, both in Ctrl-C working and in the extraneously newlines not appearing.
Ctrl-C works pretty much the way I would expect now. When pasting a document that would have taken ~20 seconds to fully paste, I hit Ctrl-C after a few seconds of the terminal hanging. This continued the pasting the rest of the lines in the document, which resulted in syntax errors. But that noise was just a minor annoyance. It would be nice to see the paste operation stop entirely when Ctrl-C is pressed (to avoid the syntax errors) but I'm fine with this current behavior for now. I expect that this will mostly be useful when my students or I accidentally paste the wrong text and then try to hit Ctrl-C to escape.
When my REPL was in this state, I pasted 604 lines of text: >>> x = 4
>>> y = """ Then when I scrolled up I saw only a couple lines above my current terminal screen (regardless of screen size this seems to be the case). >>> x = 4
... have endeavoured to discover what quality it is which he possesses that It looks like the This behavior does seem like an improvement over the many blank lines that were shown before. It would be nice to see the full history, like in the old REPL. But I can live with seeing a "tail" of the pasted text up to the current screen height instead. Thank you! |
One thing I noticed is that IPython does the same as we are doing here: you will not be able to see the full history (try it out) so this solution si also widespread. |
Maybe we can look into that afterwards |
Now pasting its much faster as well. I can paste the full Frankenstein in almost the same time as the old REPL. |
@treyhunner I tried this and Ipython also does something weird as well so I am not too concerned: |
I'm able to reproduce this same behavior in both IPython and ptpython. I've never noticed this behavior while using IPython over the years, so this must be less important to me than I thought.
I just reinstalled Python from the latest version of this branch (via https://github.com/pablogsal/cpython/archive/paste.tar.gz) and pasting the entire text of Frankenstein still seems to take ~20 seconds. I'm testing on testing on Ubuntu 22.04.4 with a fairly standard system configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Co-authored-by: Nikita Sobolev <[email protected]>
Closing in favor of #120253 |
reads more efficient.
interrumpted.
text in the REPL
Signed-off-by: Pablo Galindo [email protected]