Skip to content

unix-ffi/json: Fix json.loads() of a bytes object.#1084

Merged
dpgeorge merged 1 commit intomicropython:masterfrom
dhouck:json-loads-bytes
May 8, 2026
Merged

unix-ffi/json: Fix json.loads() of a bytes object.#1084
dpgeorge merged 1 commit intomicropython:masterfrom
dhouck:json-loads-bytes

Conversation

@dhouck
Copy link
Copy Markdown
Contributor

@dhouck dhouck commented Feb 18, 2026

The conversion from bytes to string previously worked only if some other argument was also given to loads. This makes even a basic call with no other arguments work.

NOTE: The test_json.py file fails, and failed before this PR, because of #1083. If I patch scanner.py to only parse ints (and thus not need optional groups), the tests pass.

@dhouck dhouck force-pushed the json-loads-bytes branch 2 times, most recently from c73a3fd to 38addcd Compare February 18, 2026 05:41
@dhouck dhouck changed the title Fix json.loads() of a bytes object unix-ffi/json: Fix json.loads() of a bytes object. Feb 19, 2026
@dhouck dhouck force-pushed the json-loads-bytes branch from 38addcd to df847f7 Compare May 8, 2026 13:19
@dhouck
Copy link
Copy Markdown
Contributor Author

dhouck commented May 8, 2026

Now that #1083 is fixed, the updated test_json.py now indeed works.

Copy link
Copy Markdown
Member

@dpgeorge dpgeorge left a comment

Choose a reason for hiding this comment

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

Thanks for the fix.

For reference, the original code to support bytes/bytearray was added in d1a7436

The conversion from bytes to string previosuly only if some other
argument was also given to `loads`.  This makes even a basic call with
no other arguments work.

Signed-off-by: Daniel Houck <Software@DRHouck.me>
@dpgeorge dpgeorge force-pushed the json-loads-bytes branch from df847f7 to 09a33ee Compare May 8, 2026 13:35
@dpgeorge dpgeorge merged commit 09a33ee into micropython:master May 8, 2026
5 checks passed
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.

2 participants