diff options
| author | Claude Paroz <claude@2xlibre.net> | 2017-05-10 22:39:08 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2017-05-10 22:40:18 +0200 |
| commit | f87256b15e375c6c57fe425c33ae23e116da3e84 (patch) | |
| tree | f3bd860c212e57f3a325287023ce0bb13a62a54b | |
| parent | d1e5516c06f9ee64859c1dd9888778f62fdd2bc2 (diff) | |
Refs #27795 -- Replaced force_text() with str() in contrib.messages
Thanks Tim Graham for the review.
| -rw-r--r-- | django/contrib/messages/storage/base.py | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/django/contrib/messages/storage/base.py b/django/contrib/messages/storage/base.py index 43fe3da23c..fd5d0c24aa 100644 --- a/django/contrib/messages/storage/base.py +++ b/django/contrib/messages/storage/base.py @@ -1,6 +1,5 @@ from django.conf import settings from django.contrib.messages import constants, utils -from django.utils.encoding import force_text LEVEL_TAGS = utils.get_level_tags() @@ -21,34 +20,24 @@ class Message: """ Prepare the message for serialization by forcing the ``message`` and ``extra_tags`` to str in case they are lazy translations. - - Known "safe" types (None, int, etc.) are not converted (see Django's - ``force_text`` implementation for details). """ - self.message = force_text(self.message, strings_only=True) - self.extra_tags = force_text(self.extra_tags, strings_only=True) + self.message = str(self.message) + self.extra_tags = str(self.extra_tags) if self.extra_tags is not None else None def __eq__(self, other): return isinstance(other, Message) and self.level == other.level and \ self.message == other.message def __str__(self): - return force_text(self.message) + return str(self.message) @property def tags(self): - extra_tags = force_text(self.extra_tags, strings_only=True) - if extra_tags and self.level_tag: - return ' '.join([extra_tags, self.level_tag]) - elif extra_tags: - return extra_tags - elif self.level_tag: - return self.level_tag - return '' + return ' '.join(tag for tag in [self.extra_tags, self.level_tag] if tag) @property def level_tag(self): - return force_text(LEVEL_TAGS.get(self.level, ''), strings_only=True) + return LEVEL_TAGS.get(self.level, '') class BaseStorage: |
