Skip to content

gh-154936: Fix JSON control character error position - #154941

Open
yangbaechu wants to merge 1 commit into
python:mainfrom
yangbaechu:gh-154936-json-control-character-position
Open

gh-154936: Fix JSON control character error position#154941
yangbaechu wants to merge 1 commit into
python:mainfrom
yangbaechu:gh-154936-json-control-character-position

Conversation

@yangbaechu

@yangbaechu yangbaechu commented Jul 30, 2026

Copy link
Copy Markdown

Closes #154936.

Report the actual position of invalid literal control characters in the pure Python JSON decoder. Previously, the scanner passed Match.end(), which points one character past the consumed control character, causing JSONDecodeError.pos, lineno, and colno to identify the following character instead.

Use end - 1 only in the strict invalid-control-character branch and extend the existing ASCII control-character test to verify all three location attributes for U+0000 through U+001F. The shared JSON tests cover both the pure Python and C decoders.

Tests

  • ./python -m test test_json
  • make patchcheck

Report the index of the invalid literal control character instead of
the following index in the pure Python decoder.
@python-cla-bot

python-cla-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pure Python JSON decoder reports the error position one character past an invalid control character

1 participant