From e7d62e97eb40ab441778d1dff9885b5d892d0f80 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Fri, 31 Jan 2020 11:11:24 +0100 Subject: [PATCH] Refs #22426 -- Removed pre-Django 1.5 messages compatibility code and test. This reverts commit f286721f7fdc2202f77a5f4d650d9d0779b86811. --- django/contrib/messages/storage/cookie.py | 3 --- tests/messages_tests/test_cookie.py | 21 --------------------- 2 files changed, 24 deletions(-) diff --git a/django/contrib/messages/storage/cookie.py b/django/contrib/messages/storage/cookie.py index 9e0c93e436..ad3a255fb7 100644 --- a/django/contrib/messages/storage/cookie.py +++ b/django/contrib/messages/storage/cookie.py @@ -32,9 +32,6 @@ class MessageDecoder(json.JSONDecoder): def process_messages(self, obj): if isinstance(obj, list) and obj: if obj[0] == MessageEncoder.message_key: - if len(obj) == 3: - # Compatibility with previously-encoded messages - return Message(*obj[1:]) if obj[1]: obj[3] = mark_safe(obj[3]) return Message(*obj[2:]) diff --git a/tests/messages_tests/test_cookie.py b/tests/messages_tests/test_cookie.py index 211d33f04c..48c928cb9c 100644 --- a/tests/messages_tests/test_cookie.py +++ b/tests/messages_tests/test_cookie.py @@ -153,24 +153,3 @@ class CookieTests(BaseTests, SimpleTestCase): storage = self.get_storage() self.assertIsInstance(encode_decode(mark_safe("Hello Django!")), SafeData) self.assertNotIsInstance(encode_decode("Hello Django!"), SafeData) - - def test_pre_1_5_message_format(self): - """ - Messages that were set in the cookie before the addition of is_safedata - are decoded correctly (#22426). - """ - # Encode the messages using the current encoder. - messages = [Message(constants.INFO, 'message %s') for x in range(5)] - encoder = MessageEncoder(separators=(',', ':')) - encoded_messages = encoder.encode(messages) - - # Remove the is_safedata flag from the messages in order to imitate - # the behavior of before 1.5 (monkey patching). - encoded_messages = json.loads(encoded_messages) - for obj in encoded_messages: - obj.pop(1) - encoded_messages = json.dumps(encoded_messages, separators=(',', ':')) - - # Decode the messages in the old format (without is_safedata) - decoded_messages = json.loads(encoded_messages, cls=MessageDecoder) - self.assertEqual(messages, decoded_messages)