From ed481857326606603f70ef06dbd5a4b48d1b9510 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 18 Dec 2012 10:33:14 -0800 Subject: Fix unicode conversion in Python3 --- sleekxmpp/util/misc_ops.py | 7 +++++-- 1 file 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) -- cgit v1.2.3