We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e10e9f5 commit 6a41938Copy full SHA for 6a41938
1 file changed
oca/pool.py
@@ -14,8 +14,15 @@ class WrongIdError(OpenNebulaException):
14
def extractString(xml_or_string):
15
if isinstance(xml_or_string, str):
16
return xml_or_string
17
- else:
18
- return xml_or_string.text or ''
+
+ # 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 ''
26
27
class Template(object):
28
def __init__(self, xml_element, multiple=[]):
@@ -51,7 +58,7 @@ def __init__(self, xml=None):
51
58
self.xml = xml
52
59
53
60
def _initialize_xml(self, xml, root_element):
54
- self.xml = ET.fromstring(xml)
61
+ self.xml = ET.fromstring(xml.encode('utf-8'))
55
62
if self.xml.tag != root_element.upper():
56
63
self.xml = None
57
64
self._convert_types()
0 commit comments