From 085b6b946828cc99176c9b2ba07ae2453ba579ca Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Mon, 19 Aug 2019 11:12:40 -0400 Subject: [PATCH] Fix runtime error where dict is modified during iteration. --- common/lib/xmodule/xmodule/course_module.py | 2 +- common/lib/xmodule/xmodule/tests/xml/factories.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index 809d5cc803..e6cd403148 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -1153,7 +1153,7 @@ class CourseDescriptor(CourseFields, SequenceDescriptor, LicenseMixin): # bleh, have to parse the XML here to just pull out the url_name attribute # I don't think it's stored anywhere in the instance. - course_file = BytesIO(xml_data.encode('ascii', 'ignore')) + course_file = BytesIO(six.binary_type(xml_data)) xml_obj = etree.parse(course_file, parser=edx_xml_parser).getroot() policy_dir = None diff --git a/common/lib/xmodule/xmodule/tests/xml/factories.py b/common/lib/xmodule/xmodule/tests/xml/factories.py index 0d3101a0e8..0aa282f628 100644 --- a/common/lib/xmodule/xmodule/tests/xml/factories.py +++ b/common/lib/xmodule/xmodule/tests/xml/factories.py @@ -110,7 +110,7 @@ class XmlImportFactory(Factory): if inline_xml: kwargs['xml_node'].set('not_a_pointer', 'true') - for key in kwargs.keys(): + for key in list(kwargs.keys()): if key not in XML_IMPORT_ARGS: kwargs['xml_node'].set(key, kwargs.pop(key))