moccu / django-omnibus

django-omnibus is a Django library which helps to create websocket-based connections between a browser and a server to deliver messages.
BSD 3-Clause "New" or "Revised" License
70 stars 14 forks source link

Making log functions unicode safe for unknown input. #12

Closed radiosilence closed 10 years ago

radiosilence commented 10 years ago

Issue #11

radiosilence commented 10 years ago

Ok, this still doesn't quite seem to fix it.

radiosilence commented 10 years ago

Right, second commit fixed the issue.

radiosilence commented 10 years ago

Basically, on the wire, it was picking up UTF-8 encoded bytes. Then because it was trying to format it to a string, it was trying to decode said bytes with ASCII before formatting them. And thus failed. So, you need to decode the source bytes into a unicode object using .decode('utf-8'), and make the destination string a unicode object.

coveralls commented 10 years ago

Coverage Status

Coverage remained the same when pulling 152edced0a32b65c1832a71f142088284e9eaf0c on radiosilence:master into f3c453a8fdf145e5a4ef1d5ab46fb380d6a3cab6 on moccu:master.

radiosilence commented 10 years ago

Still failing on Python 3. Hmm. It seems like the "msg" is being a bytes (str) on Python 2.7, and a unicode (str) in Python 3.

Any ideas?

coveralls commented 10 years ago

Coverage Status

Coverage remained the same when pulling c31337306c601e75fbdac9d6b9b62dcc980e04f5 on radiosilence:master into f3c453a8fdf145e5a4ef1d5ab46fb380d6a3cab6 on moccu:master.

radiosilence commented 10 years ago

This is kind of a messy solution.