From d1728b3d6a91c1c8ef7250b4c7142a395ed65da8 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Thu, 12 Sep 2019 08:40:03 -0400 Subject: [PATCH] Fixes for bokchoy running in python3. --- common/lib/xmodule/xmodule/static_content.py | 6 ++++++ tox.ini | 2 ++ 2 files changed, 8 insertions(+) diff --git a/common/lib/xmodule/xmodule/static_content.py b/common/lib/xmodule/xmodule/static_content.py index 6d276fd670..37adc9a46d 100755 --- a/common/lib/xmodule/xmodule/static_content.py +++ b/common/lib/xmodule/xmodule/static_content.py @@ -230,6 +230,12 @@ def _write_files(output_root, contents, generated_suffix_map=None): not_file = not output_file.isfile() + # Sometimes content is already unicode and sometimes it's not + # so we add this conditional here to make sure that below we're + # always working with streams of bytes. + if not isinstance(file_content, six.binary_type): + file_content = file_content.encode('utf-8') + # not_file is included to short-circuit this check, because # read_md5 depends on the file already existing write_file = not_file or output_file.read_md5() != hashlib.md5(file_content).digest() diff --git a/tox.ini b/tox.ini index 388b9e0ae7..628cfa44f4 100644 --- a/tox.ini +++ b/tox.ini @@ -61,6 +61,8 @@ passenv = XDIST_WORKER_SECURITY_GROUP XDIST_WORKER_SUBNET PYTHON_VERSION + LMS_CFG + STUDIO_CFG deps = django111: -r requirements/edx/django.txt