Skip to content

Commit 9c0afa6

Browse files
committed
Fix core.json.loads for Python3
1 parent 95050b2 commit 9c0afa6

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

pygithub3/core/json/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ def dumps(obj, cls=GHJSONEncoder, **kwargs):
3737

3838

3939
def loads(s, object_hook=gh_decoder_hook, **kwargs):
40+
if type(s) is six.binary_type:
41+
# XXX(Kagami): json module from python3 can't load bytes while
42+
# json from python2 can work with both str and unicode. Better
43+
# to get only unicode in this function but let's go this hack
44+
# for the time being. Seems like upstream bug:
45+
# <https://bugs.python.org/issue10976>.
46+
s = s.decode('utf-8')
4047
return json.loads(s, object_hook=object_hook, **kwargs)
4148

4249
dump = json.dump

0 commit comments

Comments
 (0)