GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||
GeezerVison is showing github.com — gh-156186: Fix PyREPL bracketed paste consuming the following newline by vasiliyk · Pull Request #157270 · python/cpython Conversation
|
|
@pablogsal This implements the fix you described on gh-156186: Would you be able to take a look? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@lysnikolaou, @ambv Could one of you take a look? It follows pablogsal's suggested fix on the issue: split |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| if ch == "\r": | ||
| ch = "\n" | ||
| e.data += ch | ||
| e.raw += ch.encode(self.event_queue.encoding, "replace") |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.