alexis-mignon / python-flickr-api

A python implementation of the Flickr API
BSD 3-Clause "New" or "Revised" License
367 stars 108 forks source link

findByUserName thows `JSON object must be str, not 'bytes'` #111

Closed duhaime closed 5 years ago

duhaime commented 5 years ago

Hi all, after authenticating and running user = flickr_api.Person.findByUserName('tomquirkphoto') I get:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-14-da1176ae3ed3> in <module>
----> 1 user = flickr_api.Person.findByUserName('tomquirkphoto')

~/anaconda/envs/3.5/lib/python3.5/site-packages/flickr_api/reflection.py in static_call(*args, **kwargs)
    292             method_args["auth_handler"] = token
    293             logger.debug("Calling method '%s' with arguments: %s", flickr_method, str(method_args))
--> 294             r = method_call.call_api(method=flickr_method, **method_args)
    295             try:
    296                 return format_result(r, token)

~/anaconda/envs/3.5/lib/python3.5/site-packages/flickr_api/method_call.py in call_api(api_key, api_secret, auth_handler, needssigning, request_url, raw, **args)
    142 
    143     try:
--> 144         resp = json.loads(resp.content)
    145     except ValueError as e:
    146         logger.error("Could not parse response: %s", str(resp.content))

~/anaconda/envs/3.5/lib/python3.5/json/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    310     if not isinstance(s, str):
    311         raise TypeError('the JSON object must be str, not {!r}'.format(
--> 312                             s.__class__.__name__))
    313     if s.startswith(u'\ufeff'):
    314         raise JSONDecodeError("Unexpected UTF-8 BOM (decode using utf-8-sig)",

TypeError: the JSON object must be str, not 'bytes'

The problem doesn't exist in python 2, but I wanted to flag this so all json decoding methods could be updated to account for differences between 2 and 3...