Fixed bug #353 Python3 XEP-0084 error
This commit is contained in:
parent
27582f6fd2
commit
81b7b2c190
2 changed files with 7 additions and 4 deletions
|
@ -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()
|
||||
|
|
|
@ -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 = ''
|
||||
|
||||
|
|
Loading…
Reference in a new issue