From 44b2414a5db68ee12b8a17706d04dffa7aa8f2a5 Mon Sep 17 00:00:00 2001 From: Ayub khan Date: Tue, 1 Oct 2019 12:38:35 +0500 Subject: [PATCH] BOM-804 python3 compatibility we only need to decode if the xml is bytes --- common/lib/xmodule/xmodule/modulestore/xml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/modulestore/xml.py b/common/lib/xmodule/xmodule/modulestore/xml.py index d23f4acdad..0a8d05597c 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml.py +++ b/common/lib/xmodule/xmodule/modulestore/xml.py @@ -119,7 +119,7 @@ class ImportSystem(XMLParsingSystem, MakoDescriptorSystem): orig_name = orig_name[len(tag) + 1:-12] # append the hash of the content--the first 12 bytes should be plenty. orig_name = "_" + orig_name if orig_name not in (None, "") else "" - xml_bytes = xml.encode('utf8') + xml_bytes = xml if isinstance(xml, bytes) else xml.encode('utf-8') return tag + orig_name + "_" + hashlib.sha1(xml_bytes).hexdigest()[:12] # Fallback if there was nothing we could use: