          if isinstance(obj, Message):
              # Using 0/1 here instead of False/True to produce more compact json
              is_safedata = 1 if isinstance(obj.message, SafeData) else 0
              message = [self.message_key, is_safedata, obj.level, obj.message]
              if obj.extra_tags:
                  message.append(obj.extra_tags)
              return message
          return super().default(obj)
  
  
 
</s> remove         def encode_decode(data):
            message = Message(constants.DEBUG, data)
            encoded = storage._encode(message)
            decoded = storage._decode(encoded)
            return decoded.message
 </s> add         self.assertIsInstance(
            self.encode_decode(mark_safe('<b>Hello Django!</b>')).message,
            SafeData,
        )
        self.assertNotIsInstance(
            self.encode_decode('<b>Hello Django!</b>').message,
            SafeData,
        )
            if obj.extra_tags is not None:
          if isinstance(obj, Message):
              # Using 0/1 here instead of False/True to produce more compact json
              is_safedata = 1 if isinstance(obj.message, SafeData) else 0
              message = [self.message_key, is_safedata, obj.level, obj.message]
            if obj.extra_tags is not None:
                  message.append(obj.extra_tags)
              return message
          return super().default(obj)
  
  
keep keep keep keep replace keep keep keep keep keep
 Fixed #33458 -- Fixed encoding of messages with empty string as extra_tags. 
django/contrib/messages/storage/cookie.py