Skip to content

gh-156186: Fix PyREPL bracketed paste consuming the following newline - #157270

Open
vasiliyk wants to merge 10 commits into
python:mainfrom
vasiliyk:gh-156186-bracketed-paste
Open

vasiliyk wants to merge 10 commits into
python:mainfrom
vasiliyk:gh-156186-bracketed-paste

Conversation

@vasiliyk

@vasiliyk vasiliyk commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

A newline sent right after a bracketed paste was inserted as text instead of running the block, because perform_bracketed_paste inserted everything it read, including input after the closing marker.

This implements @pablogsal's fix from the issue: accumulate event.raw, split at the first closing marker, insert the prefix, and push the rest back with push_char().

On Windows, getpending() now fills raw and joins UTF-16 surrogate pairs (reading again if a pair is split between reads), and push_char() is implemented.

@python-cla-bot

python-cla-bot Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

Comment thread Lib/test/test_pyrepl/test_pyrepl.py Resolved
Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
KoviRobi added a commit to KoviRobi/nixos-config that referenced this pull request Oct 8, 2026
@vasiliyk

vasiliyk commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@lysnikolaou, @ambv Could one of you take a look?
This fixes a 3.14 regression gh-156186.

It follows pablogsal's suggested fix on the issue: split event.raw at the first closing marker, insert the prefix, and push the rest back through the console event queue.

Comment thread Lib/test/test_pyrepl/test_pyrepl.py Resolved
Comment thread Lib/_pyrepl/windows_console.py Resolved

@pablogsal pablogsal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can getpending() return the queued input before it calls _read_input_bulk()? If one read contains two complete pastes, the second paste waits for another keypress. Can we add a Windows VT test that sends both pastes in one read and checks that each Enter submits its block?

@bedevere-app

bedevere-app Bot commented Nov 25, 2026

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@vasiliyk

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

@bedevere-app

bedevere-app Bot commented Nov 26, 2026

Copy link
Copy Markdown

Thanks for making the requested changes!

@pablogsal: please review the changes made to this pull request.

@bedevere-app
bedevere-app Bot requested a review from pablogsal November 26, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants