XEP-0084: fix setting and getting the Data value

get_value: return a bytes object
set_value: accept a bytes or a str object
This commit is contained in:
mathieui 2015-02-23 19:36:43 +01:00
parent 2ee05d9616
commit c214e4f037
No known key found for this signature in database
GPG key ID: C59F84CEEFD616E3

View file

@ -21,11 +21,11 @@ class Data(ElementBase):
def get_value(self):
if self.xml.text:
return b64decode(bytes(self.xml.text))
return ''
return b''
def set_value(self, value):
if value:
self.xml.text = b64encode(bytes(value))
self.xml.text = b64encode(bytes(value)).decode()
else:
self.xml.text = ''