Skip to content

Commit 6a41938

Browse files
authored
1 parent e10e9f5 commit 6a41938

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

oca/pool.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@ class WrongIdError(OpenNebulaException):
1414
def extractString(xml_or_string):
1515
if isinstance(xml_or_string, str):
1616
return xml_or_string
17-
else:
18-
return xml_or_string.text or ''
17+
18+
# Py2 compatibility
19+
try:
20+
if isinstance(xml_or_string, unicode):
21+
return xml_or_string
22+
except NameError:
23+
pass
24+
25+
return xml_or_string.text or ''
1926

2027
class Template(object):
2128
def __init__(self, xml_element, multiple=[]):
@@ -51,7 +58,7 @@ def __init__(self, xml=None):
5158
self.xml = xml
5259

5360
def _initialize_xml(self, xml, root_element):
54-
self.xml = ET.fromstring(xml)
61+
self.xml = ET.fromstring(xml.encode('utf-8'))
5562
if self.xml.tag != root_element.upper():
5663
self.xml = None
5764
self._convert_types()

0 commit comments

Comments
 (0)