简体   繁体   中英

TypeError during send_message in django push notifications 1.2.1, python 3.4, django 1.8.1

During firing off:

GCMDevice.send_message(message)

I get:

File "/home/vagrant/.venvs/any_dev/lib/python3.4/site-packages/push_notifications/gcm.py", line 103, in _gcm_send_json
result = json.loads(_gcm_send(data, "application/json"))
File "/usr/local/lib/python3.4/json/__init__.py", line 312, in loads
s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'

It's said that lib's python 3.x compatible, but I guess there's problem with encoding. Did anybody experienced something like that?

in gcm.py(in my case, located at ~/.virtualenvs/grape/lib/python3.4/site-packages/push_notifications/gcm.py)

replace

result = json.loads(_gcm_send(data, "application/json"))

to

result = json.loads(_gcm_send(data, "application/json").decode('utf8'))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM