Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Commit

Permalink
Fixed bug #353 Python3 XEP-0084 error
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Kellner committed Mar 25, 2015
1 parent 27582f6 commit 81b7b2c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/set_avatar.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def start(self, event):

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()
Expand Down
9 changes: 6 additions & 3 deletions sleekxmpp/plugins/xep_0084/stanza.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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 = ''

Expand Down

0 comments on commit 81b7b2c

Please sign in to comment.