Skip to content

PyREPL: Update Regex in all places - #26212

Merged
Eduardo Villalpando Mello (edvilme) merged 2 commits into
mainfrom
pyrepl-regex
Oct 7, 2026
Merged

Eduardo Villalpando Mello (edvilme) merged 2 commits into
mainfrom
pyrepl-regex

Conversation

@edvilme

@edvilme Eduardo Villalpando Mello (edvilme) commented Oct 7, 2026 •

Copy link
Copy Markdown

Before

image Description: Text does not render at carat position, but at the middle of the screen

After

image Description: Text renders correctly

Currently, pythonrc overrides the ANSI escape sequence for handling OSC codes. However, this does not get automatically updated in all references that import it.

Compatibility and escape sequence handling:

  • The initialization logic in pythonrc.py now ensures that the patched ANSI_ESCAPE_SEQUENCE regex is set before importing _pyrepl.simple_interact, making sure all _pyrepl modules use the updated regex. This prevents issues with prompt rendering and escape sequence stripping in Python 3.13+.
  • A new test, test_replacement_regex_is_imported_by_pyrepl_modules, verifies that the patched regex is correctly imported and used by both _pyrepl.reader and _pyrepl.render modules for Python 3.15 and above.

@edvilme Eduardo Villalpando Mello (edvilme) added the bug Issue identified by VS Code Team member as probable bug label Oct 7, 2026
@edvilme
Eduardo Villalpando Mello (edvilme) marked this pull request as ready for review October 7, 2026 18:06
@heejaechang

Copy link
Copy Markdown

🔒 Automated review in progress — Heejae Chang (@heejaechang) is auto-reviewing this PR.

@heejaechang

Copy link
Copy Markdown

Result: ⚠️ partially-verified

Verification details

Verification: Isolated verification observed failures that were not classified as caused by this PR: Probe patched reader and render bindings, Probe patched Python 3.13 reader binding.

Summary: The targeted shell-integration suite passed all 12 tests on Python 3.13.16, including the existing regex and prompt tests. The new Python 3.15-specific test returned before executing its assertions. Two direct probes confirmed that Python 3.13 lacks the `_pyrepl.render` module and reader binding required to verify the new behavior. Verification is therefore partial.

Test runs: 2 passed, 2 failed

  • ❌ Failed | unrelated to this PR | Probe patched reader and render bindings | python - <<'PY'
    import importlib
    import pythonrc
    from _pyrepl import utils

checked = []
for module_name in ("_pyrepl.reader", "_pyrepl.render"):
module = importlib.import_module(module_name)
regex = getattr(module, "ANSI_ESCAPE_SEQUENCE", None)
if regex is not None:
assert regex is utils.ANSI_ESCAPE_SEQUENCE
assert regex.sub("", "\x1b]633;A\x07>>> ") == ">>> "
checked.append(module_name)
assert checked
print(f"Python bindings verified: {', '.join(checked)}")
print(f"_pyrepl.render.RenderLine available: {hasattr(importlib.import_module('_pyrepl.render'), 'RenderLine')}")
PY

  • ❌ Failed | unrelated to this PR | Probe patched Python 3.13 reader binding | python - <<'PY'
    import pythonrc
    from _pyrepl import reader, utils

assert reader.ANSI_ESCAPE_SEQUENCE is utils.ANSI_ESCAPE_SEQUENCE
assert reader.ANSI_ESCAPE_SEQUENCE.sub("", "\x1b]633;A\x07>>> ") == ">>> "
print("Python 3.13 reader binding uses the patched regex and strips OSC prompts")
PY

  • ✅ Passed | Python shell integration tests | python python_files/tests/run_all.py python_files/tests/test_shell_integration.py -v
  • ✅ Passed | Dependency and test discovery | printf 'sandbox_profile=%s\n' "${AUTOMATION_SANDBOX_PROFILE:-}"; printf 'python='; python --version; printf 'pytest='; python -m pytest --version; printf 'available_pythons:\n'; command -v python3.15 || true; command -v python3.14 || true; command -v python3.13 || true; printf 'changed_files:\n'; git diff --name-status HEAD^ HEAD; printf 'test_runner:\n'; sed -n '1,220p' python_files/tests/run_all.py; printf 'python_manifest:\n'; cat python_files/pyproject.toml
❌ Probe patched reader and render bindings diagnostic output
ModuleNotFoundError: No module named '_pyrepl.render'
❌ Probe patched Python 3.13 reader binding diagnostic output
AttributeError: module '_pyrepl.reader' has no attribute 'ANSI_ESCAPE_SEQUENCE'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved via Review Center.

@heejaechang Heejae Chang (heejaechang) added the review-auto:approved Automated review: no blocking findings (approval posted). label Oct 7, 2026
@edvilme
Eduardo Villalpando Mello (edvilme) merged commit f4c86e4 into main Oct 7, 2026
92 of 96 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug review-auto:approved Automated review: no blocking findings (approval posted).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants