Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #18572 - Python26 string format incompatibility

Thanks to anonymous/AeroNotix for the report
  • Loading branch information...
commit 8fdc56d2a6f7537cdd52272501af9e94cab96ed4 1 parent d3c2eb1
@spookylukey spookylukey authored
View
4 django/contrib/admin/templatetags/admin_list.py
@@ -31,7 +31,7 @@ def paginator_number(cl,i):
if i == DOT:
return '... '
elif i == cl.page_num:
- return format_html('<span class="this-page">{}</span> ', i+1)
+ return format_html('<span class="this-page">{0}</span> ', i+1)
else:
return format_html('<a href="{0}"{1}>{2}</a> ',
cl.get_query_string({PAGE_VAR: i}),
@@ -162,7 +162,7 @@ def result_headers(cl):
"url_primary": cl.get_query_string({ORDER_VAR: '.'.join(o_list_primary)}),
"url_remove": cl.get_query_string({ORDER_VAR: '.'.join(o_list_remove)}),
"url_toggle": cl.get_query_string({ORDER_VAR: '.'.join(o_list_toggle)}),
- "class_attrib": format_html(' class="{}"', ' '.join(th_classes))
+ "class_attrib": format_html(' class="{0}"', ' '.join(th_classes))
if th_classes else '',
}
View
2  django/forms/forms.py
@@ -167,7 +167,7 @@ def _html_output(self, normal_row, error_row, row_ender, help_text_html, errors_
# punctuation.
if self.label_suffix:
if label[-1] not in ':?.!':
- label = format_html('{}{}', label, self.label_suffix)
+ label = format_html('{0}{1}', label, self.label_suffix)
label = bf.label_tag(label) or ''
else:
label = ''
View
8 django/forms/util.py
@@ -20,7 +20,7 @@ def flatatt(attrs):
The result is passed through 'mark_safe'.
"""
- return format_html_join('', ' {}="{}"', attrs.items())
+ return format_html_join('', ' {0}="{1}"', attrs.items())
class ErrorDict(dict, StrAndUnicode):
"""
@@ -33,7 +33,7 @@ def __unicode__(self):
def as_ul(self):
if not self: return ''
- return format_html('<ul class="errorlist">{}</ul>',
+ return format_html('<ul class="errorlist">{0}</ul>',
format_html_join('', '<li>{0}{1}</li>',
((k, force_unicode(v))
for k, v in self.items())
@@ -51,8 +51,8 @@ def __unicode__(self):
def as_ul(self):
if not self: return ''
- return format_html('<ul class="errorlist">{}</ul>',
- format_html_join('', '<li>{}</li>',
+ return format_html('<ul class="errorlist">{0}</ul>',
+ format_html_join('', '<li>{0}</li>',
((force_unicode(e),) for e in self)
)
)
View
12 django/forms/widgets.py
@@ -254,7 +254,7 @@ def render(self, name, value, attrs=None):
if value != '':
# Only add the 'value' attribute if a value is non-empty.
final_attrs['value'] = force_unicode(self._format_value(value))
- return format_html('<input{} />', flatatt(final_attrs))
+ return format_html('<input{0} />', flatatt(final_attrs))
class TextInput(Input):
input_type = 'text'
@@ -295,7 +295,7 @@ def render(self, name, value, attrs=None, choices=()):
# An ID attribute was given. Add a numeric index as a suffix
# so that the inputs don't all have the same ID attribute.
input_attrs['id'] = '%s_%s' % (id_, i)
- inputs.append(format_html('<input{} />', flatatt(input_attrs)))
+ inputs.append(format_html('<input{0} />', flatatt(input_attrs)))
return mark_safe('\n'.join(inputs))
def value_from_datadict(self, data, files, name):
@@ -512,7 +512,7 @@ def render(self, name, value, attrs=None):
if not (value is True or value is False or value is None or value == ''):
# Only add the 'value' attribute if a value is non-empty.
final_attrs['value'] = force_unicode(value)
- return format_html('<input{} />', flatatt(final_attrs))
+ return format_html('<input{0} />', flatatt(final_attrs))
def value_from_datadict(self, data, files, name):
if name not in data:
@@ -544,7 +544,7 @@ def __init__(self, attrs=None, choices=()):
def render(self, name, value, attrs=None, choices=()):
if value is None: value = ''
final_attrs = self.build_attrs(attrs, name=name)
- output = [format_html('<select{}>', flatatt(final_attrs))]
+ output = [format_html('<select{0}>', flatatt(final_attrs))]
options = self.render_options(choices, [value])
if options:
output.append(options)
@@ -620,7 +620,7 @@ class SelectMultiple(Select):
def render(self, name, value, attrs=None, choices=()):
if value is None: value = []
final_attrs = self.build_attrs(attrs, name=name)
- output = [format_html('<select multiple="multiple"{}>', flatatt(final_attrs))]
+ output = [format_html('<select multiple="multiple"{0}>', flatatt(final_attrs))]
options = self.render_options(choices, value)
if options:
output.append(options)
@@ -679,7 +679,7 @@ def tag(self):
final_attrs = dict(self.attrs, type='radio', name=self.name, value=self.choice_value)
if self.is_checked():
final_attrs['checked'] = 'checked'
- return format_html('<input{} />', flatatt(final_attrs))
+ return format_html('<input{0} />', flatatt(final_attrs))
class RadioFieldRenderer(StrAndUnicode):
"""
View
2  django/template/defaulttags.py
@@ -47,7 +47,7 @@ def render(self, context):
if csrf_token == 'NOTPROVIDED':
return format_html("")
else:
- return format_html("<div style='display:none'><input type='hidden' name='csrfmiddlewaretoken' value='{}' /></div>", csrf_token)
+ return format_html("<div style='display:none'><input type='hidden' name='csrfmiddlewaretoken' value='{0}' /></div>", csrf_token)
else:
# It's very probable that the token is missing because of
# misconfiguration, so we raise a warning
Please sign in to comment.
Something went wrong with that request. Please try again.