Skip to content

Commit 01fe1cd

Browse files
committed
Give json.loads str instead of bytes on TypeError #95
1 parent 8d9789d commit 01fe1cd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

wptools/utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,12 @@ def isfilename(name):
7070

7171
def json_loads(data):
7272
"""
73-
python-version safe json.loads
73+
python-version-safe json.loads
7474
"""
75-
return json.loads(data, encoding='utf-8')
75+
try:
76+
return json.loads(data, encoding='utf-8')
77+
except TypeError:
78+
return json.loads(data.decode('utf-8'))
7679

7780

7881
def pretty(data):

0 commit comments

Comments
 (0)