Skip to content

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

Open
vasiliyk wants to merge 1 commit into
python:mainfrom
vasiliyk:gh-156186-bracketed-paste
Open

gh-156186: Fix PyREPL bracketed paste consuming the following newline#157270
vasiliyk wants to merge 1 commit into
python:mainfrom
vasiliyk:gh-156186-bracketed-paste

Conversation

@vasiliyk

@vasiliyk vasiliyk commented Sep 10, 2026

Copy link
Copy Markdown

A newline sent right after a bracketed paste was inserted into the buffer instead of running the block, because perform_bracketed_paste drains all pending input and inserts everything, including what follows the closing marker.

PR implements the fix proposed by @pablogsal in the issue:
perform_bracketed_paste now accumulates event.raw, splits at the first closing marker, inserts the prefix, pushes the suffix back through the console.

Windows needed two changes to make it work:
getpending() now fills raw, and push_char() is implemented on the event queue so the suffix path works there too.

@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

def test_bracketed_paste_newline_after_end_marker(self):
# A newline arriving in the same read as the closing marker must
# execute the pasted block instead of being inserted as text.
# See #156186.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
# See #156186.
# See gh-156186.

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.

2 participants