mirror of
https://github.com/django/django.git
synced 2025-09-19 08:49:57 +00:00
Refs #27795 -- Replaced many force_text() with str()
Thanks Tim Graham for the review.
This commit is contained in:
parent
8ab7ce8558
commit
301de774c2
47 changed files with 135 additions and 181 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue