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)