GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-156186: Fix PyREPL bracketed paste consuming the following newline by vasiliyk · Pull Request #157270 · python/cpython

Conversation

@vasiliyk

@vasiliyk vasiliyk commented Sep 10, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

  • Issue: PyREPL bracketed paste issue #156186

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vasiliyk
pythongh-156186: Fix PyREPL treating input after a bracketed paste as…
6befa18
… pasted text
@vasiliyk
vasiliyk requested review from ambv, lysnikolaou and pablogsal as code owners September 10, 2026 14:08
@python-cla-bot

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

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot mentioned this pull request Sep 10, 2026
PyREPL bracketed paste issue #156186
Open
@bedevere-app bedevere-app Bot added the awaiting review label Sep 10, 2026
maurycy
maurycy reviewed Sep 10, 2026
View reviewed changes
Comment thread Lib/test/test_pyrepl/test_pyrepl.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@vasiliyk @maurycy
Use pythongh-156186 instead of python#156186 in test comment
006f06f
Co-authored-by: Maurycy Pawłowski-Wieroński <[email protected]>
KoviRobi added a commit to KoviRobi/nixos-config that referenced this pull request Oct 8, 2026
@KoviRobi
zmx: Work around python bracketed paste issue
f6428dc
Works around python/cpython#157270
@vasiliyk

vasiliyk commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

@pablogsal This implements the fix you described on gh-156186:
split at the first closing marker on event.raw, insert the prefix, and push the remaining bytes back through the console event queue.

Would you be able to take a look?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

maurycy
maurycy reviewed Nov 10, 2026
View reviewed changes
Comment thread Lib/test/test_pyrepl/test_pyrepl.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/_pyrepl/windows_console.py Outdated
if ch == "\r":
ch = "\n"
e.data += ch
e.raw += ch.encode(self.event_queue.encoding, "replace")

@maurycy maurycy Nov 10, 2026

Copy link
Copy Markdown
Contributor

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.

I think that for a pasted non-MBP it might end up as:

2026-11-10T01:30:49.482305000+0100 maurycy@gimel /Users/maurycy/work/cpython-pr157270 (pr157270 006f06f*) % ./python.exe 
Python 3.16.0a0 (heads/pr157270:6befa1828a5, Sep 10 2026, 20:04:45) [Clang 21.0.0 (clang-2100.1.1.101)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> s = chr(0xd83d) + chr(0xde00)
>>> [ch.encode("utf-8", "replace") for ch in s]
[b'?', b'?']
>>> 

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vasiliyk reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@vasiliyk vasiliyk Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

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.

Good catch. getpending() now collects the characters from a read first and joins pairs before encoding:

>>> s = "\ud83d" + "\ude00"
>>> s.encode("utf-16-le", "surrogatepass").decode("utf-16-le", "replace")
'😀'

The original per-record encode came from get_event() VT branch, which I copied, so the same issue still exists there for typed input. It is actually already reported gh-136595 :]

A pair split across two bulk reads (up to 1024 recs) still ends up as U+FFFD.
I can extend the scope a bit and add a reread if we hit it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
vasiliyk added 4 commits November 10, 2026 10:45
@vasiliyk
pythongh-156186: Join UTF-16 surrogate pairs on Windows
9ff5507
@vasiliyk
pythongh-156186: Test for Windows
93154c5
@vasiliyk
Merge remote-tracking branch 'upstream/main' into pythongh-156186-bra…
8c1e26f
…cketed-paste
@vasiliyk
Merge branch 'main' into pythongh-156186-bracketed-paste
2459a7b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@pablogsal pablogsal Awaiting requested review from pablogsal pablogsal is a code owner
@lysnikolaou lysnikolaou Awaiting requested review from lysnikolaou lysnikolaou is a code owner
@ambv ambv Awaiting requested review from ambv ambv is a code owner
1 more reviewer
@maurycy maurycy maurycy left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@vasiliyk @maurycy
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.