From f8129721d974db892d8e55ed0f4ccf7eb8528adb Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Thu, 12 Sep 2019 10:23:14 -0400 Subject: [PATCH 1/3] Fix failure during cms startup. --- openedx/core/djangoapps/user_api/accounts/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openedx/core/djangoapps/user_api/accounts/utils.py b/openedx/core/djangoapps/user_api/accounts/utils.py index 1d8b59b7bc..fdc9bf7b0d 100644 --- a/openedx/core/djangoapps/user_api/accounts/utils.py +++ b/openedx/core/djangoapps/user_api/accounts/utils.py @@ -189,7 +189,7 @@ def generate_password(length=12, chars=string.ascii_letters + string.digits): password = '' password += choice(string.digits) - password += choice(string.letters) + password += choice(string.ascii_letters) password += ''.join([choice(chars) for _i in range(length - 2)]) return password From a3d39eaeb6a91dc37c4a5cbc6cd81b8b10c6e0b6 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Thu, 12 Sep 2019 12:21:07 -0400 Subject: [PATCH 2/3] JSON takes unicode as input. In python2 there would be some auto coercion done so that the orginal code here works but that's not the case in python 3. --- common/test/acceptance/fixtures/base.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/common/test/acceptance/fixtures/base.py b/common/test/acceptance/fixtures/base.py index a327a3157c..652ae43573 100644 --- a/common/test/acceptance/fixtures/base.py +++ b/common/test/acceptance/fixtures/base.py @@ -166,10 +166,7 @@ class XBlockContainerFixture(StudioApiFixture): """ Encode `post_dict` (a dictionary) as UTF-8 encoded JSON. """ - return json.dumps({ - k: v.encode('utf-8') if isinstance(v, six.string_types) else v - for k, v in post_dict.items() - }) + return json.dumps(post_dict).encode('utf-8') def get_nested_xblocks(self, category=None): """ From fb59752c750046903ef0cd17bc9b721d7f573cde Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Thu, 12 Sep 2019 15:11:44 -0400 Subject: [PATCH 3/3] Need to return a unicode string in the xml factory. The underlying data is put into json documents that expect unicode strings not byte strings. In python2 lxml provided strings that were auto coerced but in python3 it provides byte strings. --- common/lib/capa/capa/tests/response_xml_factory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/capa/capa/tests/response_xml_factory.py b/common/lib/capa/capa/tests/response_xml_factory.py index de4c17bae3..af62ef715c 100644 --- a/common/lib/capa/capa/tests/response_xml_factory.py +++ b/common/lib/capa/capa/tests/response_xml_factory.py @@ -102,7 +102,7 @@ class ResponseXMLFactory(six.with_metaclass(ABCMeta, object)): explanation_div.set("class", "detailed-solution") explanation_div.text = explanation_text - return etree.tostring(root) + return etree.tostring(root).decode('utf-8') @staticmethod def textline_input_xml(**kwargs):