Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions unix-ffi/json/json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ def loads(
The ``encoding`` argument is ignored and deprecated.

"""
if isinstance(s, (bytes, bytearray)):
s = s.decode('utf-8')
if (
cls is None
and object_hook is None
Expand All @@ -413,6 +415,4 @@ def loads(
kw["parse_int"] = parse_int
if parse_constant is not None:
kw["parse_constant"] = parse_constant
if isinstance(s, (bytes, bytearray)):
s = s.decode('utf-8')
return cls(**kw).decode(s)
6 changes: 6 additions & 0 deletions unix-ffi/json/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@

# Doesn't work because JSON doesn't have tuples
# assert inp == outp

b = b'["foo", {"bar": ["baz", null, 1, 2]}]'
outp2 = json.loads(b)

assert b.decode('utf-8') == s
assert outp == outp2
Loading