Skip to content

gh-157928: PyREPL detect OSC sequences - #157932

Merged
brettcannon merged 9 commits into
python:mainfrom
edvilme:pyrepl-osc-escape-sequences
Oct 29, 2026
Merged

brettcannon merged 9 commits into
python:mainfrom
edvilme:pyrepl-osc-escape-sequences

Conversation

@edvilme

@edvilme edvilme commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Improve how PyREPL detects and handles OSC (Operating System Command) sequences so that they are properly recognized and accounted for when calculating string widths and rendering lines.

Enhanced the ANSI_ESCAPE_SEQUENCE regex in Lib/_pyrepl/utils.py to correctly match both CSI and OSC sequences, enabling accurate detection of OSC controls.

Before

Image Image

After

image

edvilme added a commit to microsoft/vscode-python that referenced this pull request Sep 30, 2026
Related python/cpython#157932
Related #25467

Modifies `_pyrepl.utils.ANSI_ESCAPE_SEQUENCE` to correctly support
VSCode's OSC sequences and prevent cursor misplacing when using the REPL
inside vscode.

Refactorings for easier maintainability
Comment thread Lib/_pyrepl/utils.py Outdated
Comment thread Misc/NEWS.d/next/Library/2026-09-21-21-07-12.gh-issue-157928.ZPlNYC.rst Outdated
Comment thread Lib/test/test_pyrepl/test_utils.py Outdated
Comment thread Lib/test/test_pyrepl/test_utils.py Outdated
Comment thread Lib/test/test_pyrepl/test_render.py Outdated
@bedevere-app

bedevere-app Bot commented Oct 1, 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.

@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Oct 1, 2026
@edvilme

edvilme commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

@bedevere-app

bedevere-app Bot commented Oct 2, 2026

Copy link
Copy Markdown

Thanks for making the requested changes!

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

@bedevere-app
bedevere-app Bot requested a review from brettcannon October 2, 2026 00:07
@brettcannon brettcannon added type-bug An unexpected behavior, bug, or error needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes and removed type-feature A feature request or enhancement labels Oct 29, 2026
@brettcannon brettcannon self-assigned this Oct 29, 2026
@brettcannon
brettcannon merged commit ef1fce0 into python:main Oct 29, 2026
71 of 72 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @edvilme for the PR, and @brettcannon for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @edvilme and @brettcannon, I could not cleanly backport this to 3.14 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker ef1fce0a69a19360643fb82ea3545ede21495c73 3.14

@bedevere-app

bedevere-app Bot commented Oct 29, 2026

Copy link
Copy Markdown

GH-160928 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 29, 2026
brettcannon added a commit that referenced this pull request Oct 29, 2026
gh-157928: Have PyREPL detect OSC sequences (GH-157932)
(cherry picked from commit ef1fce0)

Co-authored-by: Eduardo Villalpando Mello <[email protected]>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Brett Cannon <[email protected]>
@bedevere-app

bedevere-app Bot commented Oct 29, 2026

Copy link
Copy Markdown

GH-160935 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants