> unicode is not defined in python 3.x

I'm relying on that fact in order to differentiate between them (by catching the `NameError`). In python 2.X, we only need to do the byte conversion if the data is unicode. In python 3.X, if we have a `str`, then we need to do byte conversion.

Does that seem reasonable? Generally, I prefer doing [feature detection](http://www.html5rocks.com/en/tutorials/detection/) like this, versus detecting the python version and adding a conditional. I'm certainly open to other options, though.