Merge pull request #354 from erigones/develop
Fixed bug #353 Python3 XEP-0084 error
This commit is contained in:
commit
48857b0030
2 changed files with 7 additions and 4 deletions
|
@ -63,7 +63,7 @@ class AvatarSetter(sleekxmpp.ClientXMPP):
|
||||||
|
|
||||||
avatar_file = None
|
avatar_file = None
|
||||||
try:
|
try:
|
||||||
avatar_file = open(os.path.expanduser(self.filepath))
|
avatar_file = open(os.path.expanduser(self.filepath), 'rb')
|
||||||
except IOError:
|
except IOError:
|
||||||
print('Could not find file: %s' % self.filepath)
|
print('Could not find file: %s' % self.filepath)
|
||||||
return self.disconnect()
|
return self.disconnect()
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
from base64 import b64encode, b64decode
|
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
|
from sleekxmpp.xmlstream import ET, ElementBase, register_stanza_plugin
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,12 +20,15 @@ class Data(ElementBase):
|
||||||
|
|
||||||
def get_value(self):
|
def get_value(self):
|
||||||
if self.xml.text:
|
if self.xml.text:
|
||||||
return b64decode(bytes(self.xml.text))
|
return b64decode(sbytes(self.xml.text))
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def set_value(self, value):
|
def set_value(self, value):
|
||||||
if 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:
|
else:
|
||||||
self.xml.text = ''
|
self.xml.text = ''
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue