diff --git a/scripts/lib/email-mirror-postfix b/scripts/lib/email-mirror-postfix index ebf49f19e8..458e2faa11 100755 --- a/scripts/lib/email-mirror-postfix +++ b/scripts/lib/email-mirror-postfix @@ -81,7 +81,7 @@ MAX_ALLOWED_PAYLOAD = 25 * 1024 * 1024 def process_response_error(e: HTTPError) -> None: if e.code == 400: response_content = e.read() - response_data = json.loads(response_content.decode('utf8')) + response_data = json.loads(response_content) print(response_data['msg']) exit(posix.EX_NOUSER) else: diff --git a/zerver/tests/test_bots.py b/zerver/tests/test_bots.py index 2aab06ee80..413c7f2783 100644 --- a/zerver/tests/test_bots.py +++ b/zerver/tests/test_bots.py @@ -1574,7 +1574,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): response = self.client_post("/json/bots", bot_metadata) self.assertEqual(response.status_code, 400) expected_error_message = 'Invalid stripe_api_key value _invalid_key (stripe_api_key starts with a "_" and is hence invalid.)' - self.assertEqual(orjson.loads(response.content.decode('utf-8'))["msg"], expected_error_message) + self.assertEqual(orjson.loads(response.content)["msg"], expected_error_message) with self.assertRaises(UserProfile.DoesNotExist): UserProfile.objects.get(full_name="My Stripe Bot") @@ -1590,7 +1590,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): response = self.client_post("/json/bots", bot_metadata) self.assertEqual(response.status_code, 400) expected_error_message = "Missing configuration parameters: {'stripe_api_key'}" - self.assertEqual(orjson.loads(response.content.decode('utf-8'))["msg"], expected_error_message) + self.assertEqual(orjson.loads(response.content)["msg"], expected_error_message) with self.assertRaises(UserProfile.DoesNotExist): UserProfile.objects.get(full_name="My Stripe Bot") @@ -1619,6 +1619,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): response = self.client_post("/json/bots", bot_metadata) self.assertEqual(response.status_code, 400) expected_error_message = "Invalid integration 'stripes'." - self.assertEqual(orjson.loads(response.content.decode('utf-8'))["msg"], expected_error_message) + self.assertEqual(orjson.loads(response.content)["msg"], expected_error_message) with self.assertRaises(UserProfile.DoesNotExist): UserProfile.objects.get(full_name="My Stripe Bot") diff --git a/zerver/tests/test_message_edit.py b/zerver/tests/test_message_edit.py index 2259065cc1..d793d77394 100644 --- a/zerver/tests/test_message_edit.py +++ b/zerver/tests/test_message_edit.py @@ -249,8 +249,7 @@ class EditMessageTest(ZulipTestCase): messages_result = self.client_get("/json/messages", {"anchor": msg_id_1, "num_before": 0, "num_after": 10}) self.assert_json_success(messages_result) - json_messages = orjson.loads( - messages_result.content.decode('utf-8')) + json_messages = orjson.loads(messages_result.content) for msg in json_messages['messages']: self.assertNotIn("edit_history", msg) @@ -271,8 +270,7 @@ class EditMessageTest(ZulipTestCase): message_edit_history_1 = self.client_get( "/json/messages/" + str(msg_id_1) + "/history") - json_response_1 = orjson.loads( - message_edit_history_1.content.decode('utf-8')) + json_response_1 = orjson.loads(message_edit_history_1.content) message_history_1 = json_response_1['message_history'] # Check content of message after edit. @@ -307,8 +305,7 @@ class EditMessageTest(ZulipTestCase): message_edit_history_2 = self.client_get( "/json/messages/" + str(msg_id_2) + "/history") - json_response_2 = orjson.loads( - message_edit_history_2.content.decode('utf-8')) + json_response_2 = orjson.loads(message_edit_history_2.content) message_history_2 = json_response_2['message_history'] self.assertEqual(message_history_2[0]['rendered_content'], @@ -342,8 +339,7 @@ class EditMessageTest(ZulipTestCase): message_edit_history_1 = self.client_get( "/json/messages/" + str(msg_id_1) + "/history") - json_response_1 = orjson.loads( - message_edit_history_1.content.decode('utf-8')) + json_response_1 = orjson.loads(message_edit_history_1.content) message_history_1 = json_response_1['message_history'] # Check content of message after edit. @@ -469,7 +465,7 @@ class EditMessageTest(ZulipTestCase): # correct filled-out fields message_edit_history = self.client_get("/json/messages/" + str(msg_id) + "/history") - json_response = orjson.loads(message_edit_history.content.decode('utf-8')) + json_response = orjson.loads(message_edit_history.content) # We reverse the message history view output so that the IDs line up with the above. message_history = list(reversed(json_response['message_history'])) diff --git a/zerver/tests/test_message_send.py b/zerver/tests/test_message_send.py index 512c22299b..742faace02 100644 --- a/zerver/tests/test_message_send.py +++ b/zerver/tests/test_message_send.py @@ -323,7 +323,7 @@ class MessagePOSTTest(ZulipTestCase): "client": "test suite", "to": othello.email}) self.assert_json_success(result) - message_id = orjson.loads(result.content.decode())['id'] + message_id = orjson.loads(result.content)['id'] recent_conversations = get_recent_private_conversations(user_profile) self.assertEqual(len(recent_conversations), 1) @@ -338,7 +338,7 @@ class MessagePOSTTest(ZulipTestCase): "client": "test suite", "to": user_profile.email}) self.assert_json_success(result) - self_message_id = orjson.loads(result.content.decode())['id'] + self_message_id = orjson.loads(result.content)['id'] recent_conversations = get_recent_private_conversations(user_profile) self.assertEqual(len(recent_conversations), 2) diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py index 4fd405075f..dae28be64e 100644 --- a/zerver/tests/test_subs.py +++ b/zerver/tests/test_subs.py @@ -306,7 +306,7 @@ class TestCreateStreams(ZulipTestCase): "already_subscribed": {}, } self.assertEqual(response.status_code, 200) - self.assertEqual(orjson.loads(response.content.decode()), expected_response) + self.assertEqual(orjson.loads(response.content), expected_response) # 2 messages should be created, one in announce and one in the new stream itself. self.assertEqual(final_message_count - initial_message_count, 2) diff --git a/zerver/views/video_calls.py b/zerver/views/video_calls.py index 78b8ad1218..9d3d3e52d5 100644 --- a/zerver/views/video_calls.py +++ b/zerver/views/video_calls.py @@ -144,7 +144,7 @@ def make_zoom_video_call(request: HttpRequest, user: UserProfile) -> HttpRespons @require_POST @has_request_variables def deauthorize_zoom_user(request: HttpRequest) -> HttpResponse: - data = json.loads(request.body.decode("utf-8")) + data = json.loads(request.body) payload = data["payload"] if payload["user_data_retention"] == "false": requests.post(