diff options
author | Lance Stout <lancestout@gmail.com> | 2012-12-18 10:33:14 -0800 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2012-12-18 10:33:14 -0800 |
commit | ed481857326606603f70ef06dbd5a4b48d1b9510 (patch) | |
tree | 55984c369e72124f6d375dadcc0ff25168d0043a /sleekxmpp/util/misc_ops.py | |
parent | 8b29900be459dffcb32a9fc106caebbbf93e5b33 (diff) | |
download | slixmpp-ed481857326606603f70ef06dbd5a4b48d1b9510.tar.gz slixmpp-ed481857326606603f70ef06dbd5a4b48d1b9510.tar.bz2 slixmpp-ed481857326606603f70ef06dbd5a4b48d1b9510.tar.xz slixmpp-ed481857326606603f70ef06dbd5a4b48d1b9510.zip |
Fix unicode conversion in Python3
Diffstat (limited to 'sleekxmpp/util/misc_ops.py')
-rw-r--r-- | sleekxmpp/util/misc_ops.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sleekxmpp/util/misc_ops.py b/sleekxmpp/util/misc_ops.py index 3b246625..c2533eec 100644 --- a/sleekxmpp/util/misc_ops.py +++ b/sleekxmpp/util/misc_ops.py @@ -8,7 +8,10 @@ def unicode(text): text = text.decode('utf-8') import __builtin__ return __builtin__.unicode(text) - return str(text) + elif not isinstance(text, str): + return text.decode('utf-8') + else: + return text def bytes(text): @@ -148,4 +151,4 @@ def setdefaultencoding(encoding): if func is None: raise RuntimeError("Could not find setdefaultencoding") sys.setdefaultencoding = func - return func(encoding)
\ No newline at end of file + return func(encoding) |