Loading django/contrib/sessions/backends/base.py +1 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ class SessionBase(object): "Returns the given session dictionary pickled and encoded as a string." pickled = pickle.dumps(session_dict, pickle.HIGHEST_PROTOCOL) hash = self._hash(pickled) return base64.b64encode(hash.encode() + b":" + pickled) return base64.b64encode(hash.encode() + b":" + pickled).decode('ascii') def decode(self, session_data): encoded_data = base64.b64decode(smart_bytes(session_data)) Loading tests/regressiontests/test_client_regress/tests.py +2 −2 Original line number Diff line number Diff line Loading @@ -858,7 +858,7 @@ class UnicodePayloadTests(TestCase): json = '{"english": "mountain pass"}' response = self.client.post("/test_client_regress/parse_unicode_json/", json, content_type="application/json") self.assertEqual(response.content, json) self.assertEqual(response.content, json.encode()) def test_unicode_payload_utf8(self): "A non-ASCII unicode data encoded as UTF-8 can be POSTed" Loading Loading @@ -888,7 +888,7 @@ class DummyFile(object): def __init__(self, filename): self.name = filename def read(self): return 'TEST_FILE_CONTENT' return b'TEST_FILE_CONTENT' class UploadedFileEncodingTest(TestCase): def test_file_encoding(self): Loading tests/regressiontests/test_client_regress/views.py +1 −3 Original line number Diff line number Diff line Loading @@ -80,9 +80,7 @@ def return_json_file(request): # This just checks that the uploaded data is JSON obj_dict = json.loads(request.body.decode(charset)) obj_json = json.dumps(obj_dict, encoding=charset, cls=DjangoJSONEncoder, ensure_ascii=False) obj_json = json.dumps(obj_dict, cls=DjangoJSONEncoder, ensure_ascii=False) response = HttpResponse(obj_json.encode(charset), status=200, content_type='application/json; charset=%s' % charset) response['Content-Disposition'] = 'attachment; filename=testfile.json' Loading Loading
django/contrib/sessions/backends/base.py +1 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ class SessionBase(object): "Returns the given session dictionary pickled and encoded as a string." pickled = pickle.dumps(session_dict, pickle.HIGHEST_PROTOCOL) hash = self._hash(pickled) return base64.b64encode(hash.encode() + b":" + pickled) return base64.b64encode(hash.encode() + b":" + pickled).decode('ascii') def decode(self, session_data): encoded_data = base64.b64decode(smart_bytes(session_data)) Loading
tests/regressiontests/test_client_regress/tests.py +2 −2 Original line number Diff line number Diff line Loading @@ -858,7 +858,7 @@ class UnicodePayloadTests(TestCase): json = '{"english": "mountain pass"}' response = self.client.post("/test_client_regress/parse_unicode_json/", json, content_type="application/json") self.assertEqual(response.content, json) self.assertEqual(response.content, json.encode()) def test_unicode_payload_utf8(self): "A non-ASCII unicode data encoded as UTF-8 can be POSTed" Loading Loading @@ -888,7 +888,7 @@ class DummyFile(object): def __init__(self, filename): self.name = filename def read(self): return 'TEST_FILE_CONTENT' return b'TEST_FILE_CONTENT' class UploadedFileEncodingTest(TestCase): def test_file_encoding(self): Loading
tests/regressiontests/test_client_regress/views.py +1 −3 Original line number Diff line number Diff line Loading @@ -80,9 +80,7 @@ def return_json_file(request): # This just checks that the uploaded data is JSON obj_dict = json.loads(request.body.decode(charset)) obj_json = json.dumps(obj_dict, encoding=charset, cls=DjangoJSONEncoder, ensure_ascii=False) obj_json = json.dumps(obj_dict, cls=DjangoJSONEncoder, ensure_ascii=False) response = HttpResponse(obj_json.encode(charset), status=200, content_type='application/json; charset=%s' % charset) response['Content-Disposition'] = 'attachment; filename=testfile.json' Loading