diff options
author | Richard Kellner <richard.kellner@erigones.com> | 2015-03-25 14:04:46 +0100 |
---|---|---|
committer | Richard Kellner <richard.kellner@erigones.com> | 2015-03-25 14:04:46 +0100 |
commit | 81b7b2c1908e0f6a5435ce67745b5f4dafb59816 (patch) | |
tree | 8d21edf12868f0ce3e5581c83394e194ea77de74 | |
parent | 27582f6fd29e365253e7f3bf2e318a5403da9b73 (diff) | |
download | slixmpp-81b7b2c1908e0f6a5435ce67745b5f4dafb59816.tar.gz slixmpp-81b7b2c1908e0f6a5435ce67745b5f4dafb59816.tar.bz2 slixmpp-81b7b2c1908e0f6a5435ce67745b5f4dafb59816.tar.xz slixmpp-81b7b2c1908e0f6a5435ce67745b5f4dafb59816.zip |
Fixed bug #353 Python3 XEP-0084 error
-rwxr-xr-x | examples/set_avatar.py | 2 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0084/stanza.py | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/examples/set_avatar.py b/examples/set_avatar.py index cae93c99..08e0b664 100755 --- a/examples/set_avatar.py +++ b/examples/set_avatar.py @@ -63,7 +63,7 @@ class AvatarSetter(sleekxmpp.ClientXMPP): avatar_file = None try: - avatar_file = open(os.path.expanduser(self.filepath)) + avatar_file = open(os.path.expanduser(self.filepath), 'rb') except IOError: print('Could not find file: %s' % self.filepath) return self.disconnect() diff --git a/sleekxmpp/plugins/xep_0084/stanza.py b/sleekxmpp/plugins/xep_0084/stanza.py index 22f11b72..fd21e6f1 100644 --- a/sleekxmpp/plugins/xep_0084/stanza.py +++ b/sleekxmpp/plugins/xep_0084/stanza.py @@ -8,7 +8,7 @@ from base64 import b64encode, b64decode -from sleekxmpp.util import bytes +from sleekxmpp.util import bytes as sbytes from sleekxmpp.xmlstream import ET, ElementBase, register_stanza_plugin @@ -20,12 +20,15 @@ class Data(ElementBase): def get_value(self): if self.xml.text: - return b64decode(bytes(self.xml.text)) + return b64decode(sbytes(self.xml.text)) return '' def set_value(self, value): if value: - self.xml.text = b64encode(bytes(value)) + self.xml.text = b64encode(sbytes(value)) + # Python3 base64 encoded is bytes and needs to be decoded to string + if isinstance(self.xml.text, bytes): + self.xml.text = self.xml.text.decode() else: self.xml.text = '' |