Refs #27795 -- Replaced many force_text() with str()

Thanks Tim Graham for the review.
This commit is contained in:
Claude Paroz 2017-04-21 19:52:26 +02:00
parent 8ab7ce8558
commit 301de774c2
47 changed files with 135 additions and 181 deletions

View file

@ -18,7 +18,6 @@ import time
from django.utils.dates import (
MONTHS, MONTHS_3, MONTHS_ALT, MONTHS_AP, WEEKDAYS, WEEKDAYS_ABBR,
)
from django.utils.encoding import force_text
from django.utils.timezone import get_default_timezone, is_aware, is_naive
from django.utils.translation import gettext as _
@ -29,14 +28,14 @@ re_escaped = re.compile(r'\\(.)')
class Formatter:
def format(self, formatstr):
pieces = []
for i, piece in enumerate(re_formatchars.split(force_text(formatstr))):
for i, piece in enumerate(re_formatchars.split(str(formatstr))):
if i % 2:
if type(self.data) is datetime.date and hasattr(TimeFormat, piece):
raise TypeError(
"The format for date objects may not contain "
"time-related format specifiers (found '%s')." % piece
)
pieces.append(force_text(getattr(self, piece)()))
pieces.append(str(getattr(self, piece)()))
elif piece:
pieces.append(re_escaped.sub(r'\1', piece))
return ''.join(pieces)