diff options
author | Sergey Fedoseev <fedoseev.sergey@gmail.com> | 2018-07-09 20:25:11 +0500 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2018-07-09 11:25:11 -0400 |
commit | 857f860d5628d9d9a60eb0ab858647211fb8bb01 (patch) | |
tree | 919639370b4cbc05b292e28bab9164c221070d6e | |
parent | c9088cfc7bdf035a2a28582f1be6acce1c30b8ef (diff) | |
download | django-857f860d5628d9d9a60eb0ab858647211fb8bb01.tar.gz |
Removed unneded str() calls prior to mark_safe(); simplified mark_safe().
-rw-r--r-- | django/template/defaultfilters.py | 2 | ||||
-rw-r--r-- | django/utils/numberformat.py | 2 | ||||
-rw-r--r-- | django/utils/safestring.py | 6 |
3 files changed, 4 insertions, 6 deletions
diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py index ef7ae8679d..53b9ade716 100644 --- a/django/template/defaultfilters.py +++ b/django/template/defaultfilters.py @@ -448,7 +448,7 @@ def safeseq(value): individually, as safe, after converting them to strings. Return a list with the results. """ - return [mark_safe(str(obj)) for obj in value] + return [mark_safe(obj) for obj in value] @register.filter(is_safe=True) diff --git a/django/utils/numberformat.py b/django/utils/numberformat.py index c6f9af6893..4dc37ae22b 100644 --- a/django/utils/numberformat.py +++ b/django/utils/numberformat.py @@ -23,7 +23,7 @@ def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='', use_grouping = use_grouping and grouping != 0 # Make the common case fast if isinstance(number, int) and not use_grouping and not decimal_pos: - return mark_safe(str(number)) + return mark_safe(number) # sign sign = '' if isinstance(number, Decimal): diff --git a/django/utils/safestring.py b/django/utils/safestring.py index 2da467a079..5128add622 100644 --- a/django/utils/safestring.py +++ b/django/utils/safestring.py @@ -5,7 +5,7 @@ that the producer of the string has already turned characters that should not be interpreted by the HTML engine (e.g. '<') into the appropriate entities. """ -from django.utils.functional import Promise, wraps +from django.utils.functional import wraps class SafeData: @@ -79,8 +79,6 @@ def mark_safe(s): """ if hasattr(s, '__html__'): return s - if isinstance(s, (str, Promise)): - return SafeText(s) if callable(s): return _safety_decorator(mark_safe, s) - return SafeText(str(s)) + return SafeText(s) |