Skip to content

gh-162028: Fix the pure Python JSON decoder error position for invalid escapes - #162029

Merged
vstinner merged 3 commits into
python:mainfrom
thejesh23:json-escape-pos
Nov 16, 2026
Merged

vstinner merged 3 commits into
python:mainfrom
thejesh23:json-escape-pos

Conversation

@thejesh23

@thejesh23 thejesh23 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

The pure Python decoder now reports the position of the backslash for an invalid \escape, like the C decoder.

Tested locally:

  • Without the fix, the new test passes for C and fails for Python (off by one).
  • With the fix, it passes for both.

…decoder

The C decoder reports the position of the backslash. The pure Python
decoder reported the position of the character after it.

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@vstinner vstinner added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Nov 16, 2026
@vstinner
vstinner merged commit 5e18bfc into python:main Nov 16, 2026
61 checks passed
@miss-islington-app

Copy link
Copy Markdown

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

@bedevere-app

bedevere-app Bot commented Nov 16, 2026

Copy link
Copy Markdown

GH-162122 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 Nov 16, 2026
@bedevere-app

bedevere-app Bot commented Nov 16, 2026

Copy link
Copy Markdown

GH-162123 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 Nov 16, 2026
@vstinner

Copy link
Copy Markdown
Member

Merged, thanks for your fix! Hopefully, the Python implementation is not used by default on Python (only if you manually disable the C extension). I backported your change to 3.14 and 3.15 stable branches.

vstinner pushed a commit that referenced this pull request Nov 16, 2026
… invalid escapes (GH-162029) (#162122)

gh-162028: Fix the pure Python JSON decoder error position for invalid escapes (GH-162029)

The C decoder reports the position of the backslash. The pure Python
decoder reported the position of the character after it.
(cherry picked from commit 5e18bfc)

Co-authored-by: Thejesh <thejesh36@gmail.com>
vstinner pushed a commit that referenced this pull request Nov 16, 2026
… invalid escapes (GH-162029) (#162123)

gh-162028: Fix the pure Python JSON decoder error position for invalid escapes (GH-162029)

The C decoder reports the position of the backslash. The pure Python
decoder reported the position of the character after it.
(cherry picked from commit 5e18bfc)

Co-authored-by: Thejesh <thejesh36@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants