Repository navigation
Python: make the memory markdown escape invertible for backslash runs - #9728
Open
Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
Open
Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
Conversation
Escaping a line that already started with backslash hash added one more backslash the reader never stripped, so every reload corrupted the line a little more. The escape now maps a run of n backslashes before a hash to 2n plus 1, and the reader reduces an odd run back to the original count; even runs were not written here and pass through untouched. Plain hash lines keep the existing single backslash behavior. Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
Manohar Paturi (ManoharPaturi)
requested review from
SergeyMenshykh,
Tao Chen (TaoChenOSU),
Eduard van Valkenburg (eavanvalkenburg),
Giles Odigwe (giles17),
Jose Alvarez (jpalvarezl),
Evan Mattson (moonbox3),
Roger Barreto (rogerbarreto),
sophia-ramsey and
westey (westey-m)
as code owners
October 26, 2026 18:04
Manohar Paturi (ManoharPaturi)
temporarily deployed
to
github-app-auth
October 26, 2026 18:04 — with
GitHub Actions
Inactive
Manohar Paturi (ManoharPaturi)
temporarily deployed
to
github-app-auth
October 26, 2026 18:05 — with
GitHub Actions
Inactive
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation & Context
_escape_markdown_lineprepended one backslash to any line starting with#or\#, but_unescape_markdown_lineonly stripped a backslash from a body starting with exactly\#. A line that already began with an escaped hash therefore gained a backslash on every write and read cycle, and the corruption compounded across the rereads that auto loading and consolidation perform. Reproduced on main with a one line round trip:\# literal factcame back as\\# literal fact.Description & Review Guide
nbackslashes before a hash to2n + 1, and the reader reduces an odd run back to the originaln. A plain#line still gets the single backslash it always had, which is then = 0case.Related Issue
Fixes #9727
AI Assistance