From 9180afe0ee5f7c2569a1fce9d7d2c3ef6772a19f Mon Sep 17 00:00:00 2001 From: "Vikrant Balyan (vvb)" Date: Fri, 24 Aug 2018 03:05:42 +0530 Subject: [PATCH] Python2&3 compatibility Signed-off-by: Vikrant Balyan (vvb) --- imcsdk/imcxmlcodec.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/imcsdk/imcxmlcodec.py b/imcsdk/imcxmlcodec.py index 2ed65fd8..ad10edb7 100644 --- a/imcsdk/imcxmlcodec.py +++ b/imcsdk/imcxmlcodec.py @@ -58,7 +58,8 @@ def extract_root_elem(xml_str): ''' root_element = extract_root_elem(xml_str) """ - + if type(xml_str) is not str: + xml_str = xml_str.decode('utf-8') xml_str = xml_str.strip("\x00") root_elem = ET.fromstring(xml_str) return root_elem @@ -82,7 +83,8 @@ def from_xml_str(xml_str, handle=None): '''\n root_element = extract_root_elem(xml_str)\n """ - + if type(xml_str) is not str: + xml_str = xml_str.decode('utf-8') xml_str = xml_str.strip("\x00") root_elem = ET.fromstring(xml_str) if root_elem.tag == "error":