From 69c73ce211b24d37e3a9a2e4564365547e2822cc Mon Sep 17 00:00:00 2001 From: aarif Date: Tue, 1 Oct 2019 15:28:11 +0500 Subject: [PATCH] Updated the API to properly parse Query parameters to make it compatible with python 3 --- common/djangoapps/terrain/stubs/http.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/djangoapps/terrain/stubs/http.py b/common/djangoapps/terrain/stubs/http.py index 1213a1ef22..3b041b0bb5 100644 --- a/common/djangoapps/terrain/stubs/http.py +++ b/common/djangoapps/terrain/stubs/http.py @@ -111,7 +111,7 @@ class StubHttpRequestHandler(BaseHTTPRequestHandler, object): # None of our parameters are lists, however, so we map [val] --> val # If the list contains multiple entries, we pick the first one try: - post_dict = six.moves.urllib.parse.parse_qs(contents, keep_blank_values=True) + post_dict = six.moves.urllib.parse.parse_qs(contents.decode('utf-8'), keep_blank_values=True) return { key: list_val[0] for key, list_val in post_dict.items() @@ -161,8 +161,8 @@ class StubHttpRequestHandler(BaseHTTPRequestHandler, object): # Decode the params as UTF-8 try: - key = six.text_type(key, 'utf-8') - value = six.text_type(value, 'utf-8') + key = six.text_type(key) + value = six.text_type(value) except UnicodeDecodeError: self.log_message("Could not decode request params as UTF-8")