| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
raw_decode currently ignores leading whitespace before JSON values,
raising JSONDecodeError on strings like ' {"key": "value"}'. This is
inconsistent with JSONDecoder.decode() which handles leading whitespace.
Add s = s.lstrip() at the start of raw_decode to strip leading
whitespace before decoding, matching the behavior of decode().
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead. |
Sorry, something went wrong.
|
The following commit authors need to sign the Contributor License Agreement: |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Fixes #59598
JSONDecoder.raw_decode() raises JSONDecodeError on strings with leading whitespace (e.g., ' {"key": "value"}'), while JSONDecoder.decode() handles it fine. This is inconsistent behavior.
Changes
Add s = s.lstrip() at the start of raw_decode() to strip leading whitespace before decoding, matching the behavior of decode().
Test
This matches the behavior of decoder.decode(' {"key": "value"}') which already works correctly.