bitly/pynsq — pull request #48 by rymo4 (2013-08-12 22:32:15+00:00)
Title: Make sure a unicode param doesn't force other strings into unicode

The line `return "%s%s%s%s" % (cmd, params_data, NL, body_data)` concatenates four strings, some of which can be unicode strings. Python then tries to convert the other strings into unicode (if you have no LANG telling it to use utf8 in your env), potentially throwing things like this:

```
Traceback (most recent call last):
File "/bitly/local/lib/python2.5/site-packages/nsq/Writer.py", line 123, in _pub
conn.send(cmd(topic, msg))
File "/bitly/local/lib/python2.5/site-packages/nsq/nsq.py", line 151, in pub
return _command('PUB', data, topic)
File "/bitly/local/lib/python2.5/site-packages/nsq/nsq.py", line 122, in _command
return "%s%s%s%s" % (cmd, params_data, NL, body_data)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb7 in position 3: ordinal not in range(128)
```

This makes sure that everything is utf8.