Ah you're right. I wasn't thinking clearly there at all.  So are you thinking leave in `isinstance(msg, unicode)`?  Or just go straight to `msg.encode('utf-8')` assuming the message is unicode?  If so that should only happen on Python 2 (since in Python 3 if it's already a unicode string nothing more needs to be done).