Removed unneded str() calls prior to mark_safe(); simplified mark_safe().

This commit is contained in:
Sergey Fedoseev 2018-07-09 20:25:11 +05:00 committed by Tim Graham
parent c9088cfc7b
commit 857f860d56
3 changed files with 4 additions and 6 deletions

View File

@ -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)

View File

@ -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):

View File

@ -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)