diff --git a/common/djangoapps/track/views/__init__.py b/common/djangoapps/track/views/__init__.py
index 6b0bd06357..d36a3d8eca 100644
--- a/common/djangoapps/track/views/__init__.py
+++ b/common/djangoapps/track/views/__init__.py
@@ -121,7 +121,7 @@ def server_track(request, event_type, event, page=None):
"event_source": "server",
"event_type": event_type,
"event": event,
- "agent": _get_request_header(request, 'HTTP_USER_AGENT').decode('latin1'),
+ "agent": _get_request_header(request, 'HTTP_USER_AGENT').encode().decode('latin1'),
"page": page,
"time": datetime.datetime.utcnow().replace(tzinfo=pytz.utc),
"host": _get_request_header(request, 'SERVER_NAME'),
diff --git a/lms/djangoapps/bulk_email/tests/test_course_optout.py b/lms/djangoapps/bulk_email/tests/test_course_optout.py
index 225ae65cac..8407889567 100644
--- a/lms/djangoapps/bulk_email/tests/test_course_optout.py
+++ b/lms/djangoapps/bulk_email/tests/test_course_optout.py
@@ -57,7 +57,7 @@ class TestOptoutCourseEmails(ModuleStoreTestCase):
response = self.client.get(url)
email_section = '
'
# If this fails, it is likely because BulkEmailFlag.is_enabled() is set to False
- self.assertIn(email_section, response.content)
+ self.assertIn(email_section, response.content.decode('utf-8'))
def test_optout_course(self):
"""
diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py
index 2fb8489fe0..0c596b73bf 100644
--- a/lms/djangoapps/instructor/views/instructor_dashboard.py
+++ b/lms/djangoapps/instructor/views/instructor_dashboard.py
@@ -739,7 +739,7 @@ def _section_send_email(course, access):
usage_id_serializer=lambda usage_id: quote_slashes(six.text_type(usage_id)),
# Generate a new request_token here at random, because this module isn't connected to any other
# xblock rendering.
- request_token=uuid.uuid1().get_hex()
+ request_token=uuid.uuid1().hex
)
cohorts = []
if is_course_cohorted(course_key):
diff --git a/lms/djangoapps/instructor_task/api.py b/lms/djangoapps/instructor_task/api.py
index b587aa4a1a..52c06bb68a 100644
--- a/lms/djangoapps/instructor_task/api.py
+++ b/lms/djangoapps/instructor_task/api.py
@@ -320,7 +320,7 @@ def submit_bulk_course_email(request, course_key, email_id):
task_input = {'email_id': email_id, 'to_option': targets}
task_key_stub = str(email_id)
# create the key value by using MD5 hash:
- task_key = hashlib.md5(task_key_stub).hexdigest()
+ task_key = hashlib.md5(task_key_stub.encode('utf-8')).hexdigest()
return submit_task(request, task_type, task_class, course_key, task_input, task_key)
diff --git a/lms/djangoapps/instructor_task/api_helper.py b/lms/djangoapps/instructor_task/api_helper.py
index 77dba670be..10afaef641 100644
--- a/lms/djangoapps/instructor_task/api_helper.py
+++ b/lms/djangoapps/instructor_task/api_helper.py
@@ -140,7 +140,7 @@ def _get_xmodule_instance_args(request, task_id):
request_info = {'username': request.user.username,
'user_id': request.user.id,
'ip': request.META['REMOTE_ADDR'],
- 'agent': request.META.get('HTTP_USER_AGENT', '').decode('latin1'),
+ 'agent': request.META.get('HTTP_USER_AGENT', '').encode().decode('latin1'),
'host': request.META['SERVER_NAME'],
}
diff --git a/lms/templates/experiments/user_metadata.html b/lms/templates/experiments/user_metadata.html
index 00a1a3daa4..d4b0ba0963 100644
--- a/lms/templates/experiments/user_metadata.html
+++ b/lms/templates/experiments/user_metadata.html
@@ -59,7 +59,7 @@ if course_key:
}
if not course_id:
- user_metadata['course_id'] = unicode(course_key)
+ user_metadata['course_id'] = six.text_type(course_key)
elif isinstance(course_key, six.string_types):
user_metadata['course_id'] = course_key