Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #18572 - Python26 string format incompatibility

Thanks to anonymous/AeroNotix for the report
  • Loading branch information...
commit 8fdc56d2a6f7537cdd52272501af9e94cab96ed4 1 parent d3c2eb1
Luke Plant authored July 05, 2012
4  django/contrib/admin/templatetags/admin_list.py
@@ -31,7 +31,7 @@ def paginator_number(cl,i):
31 31
     if i == DOT:
32 32
         return '... '
33 33
     elif i == cl.page_num:
34  
-        return format_html('<span class="this-page">{}</span> ', i+1)
  34
+        return format_html('<span class="this-page">{0}</span> ', i+1)
35 35
     else:
36 36
         return format_html('<a href="{0}"{1}>{2}</a> ',
37 37
                            cl.get_query_string({PAGE_VAR: i}),
@@ -162,7 +162,7 @@ def result_headers(cl):
162 162
             "url_primary": cl.get_query_string({ORDER_VAR: '.'.join(o_list_primary)}),
163 163
             "url_remove": cl.get_query_string({ORDER_VAR: '.'.join(o_list_remove)}),
164 164
             "url_toggle": cl.get_query_string({ORDER_VAR: '.'.join(o_list_toggle)}),
165  
-            "class_attrib": format_html(' class="{}"', ' '.join(th_classes))
  165
+            "class_attrib": format_html(' class="{0}"', ' '.join(th_classes))
166 166
                             if th_classes else '',
167 167
         }
168 168
 
2  django/forms/forms.py
@@ -167,7 +167,7 @@ def _html_output(self, normal_row, error_row, row_ender, help_text_html, errors_
167 167
                     # punctuation.
168 168
                     if self.label_suffix:
169 169
                         if label[-1] not in ':?.!':
170  
-                            label = format_html('{}{}', label, self.label_suffix)
  170
+                            label = format_html('{0}{1}', label, self.label_suffix)
171 171
                     label = bf.label_tag(label) or ''
172 172
                 else:
173 173
                     label = ''
8  django/forms/util.py
@@ -20,7 +20,7 @@ def flatatt(attrs):
20 20
 
21 21
     The result is passed through 'mark_safe'.
22 22
     """
23  
-    return format_html_join('', ' {}="{}"', attrs.items())
  23
+    return format_html_join('', ' {0}="{1}"', attrs.items())
24 24
 
25 25
 class ErrorDict(dict, StrAndUnicode):
26 26
     """
@@ -33,7 +33,7 @@ def __unicode__(self):
33 33
 
34 34
     def as_ul(self):
35 35
         if not self: return ''
36  
-        return format_html('<ul class="errorlist">{}</ul>',
  36
+        return format_html('<ul class="errorlist">{0}</ul>',
37 37
                            format_html_join('', '<li>{0}{1}</li>',
38 38
                                             ((k, force_unicode(v))
39 39
                                              for k, v in self.items())
@@ -51,8 +51,8 @@ def __unicode__(self):
51 51
 
52 52
     def as_ul(self):
53 53
         if not self: return ''
54  
-        return format_html('<ul class="errorlist">{}</ul>',
55  
-                           format_html_join('', '<li>{}</li>',
  54
+        return format_html('<ul class="errorlist">{0}</ul>',
  55
+                           format_html_join('', '<li>{0}</li>',
56 56
                                             ((force_unicode(e),) for e in self)
57 57
                                             )
58 58
                            )
12  django/forms/widgets.py
@@ -254,7 +254,7 @@ def render(self, name, value, attrs=None):
254 254
         if value != '':
255 255
             # Only add the 'value' attribute if a value is non-empty.
256 256
             final_attrs['value'] = force_unicode(self._format_value(value))
257  
-        return format_html('<input{} />', flatatt(final_attrs))
  257
+        return format_html('<input{0} />', flatatt(final_attrs))
258 258
 
259 259
 class TextInput(Input):
260 260
     input_type = 'text'
@@ -295,7 +295,7 @@ def render(self, name, value, attrs=None, choices=()):
295 295
                 # An ID attribute was given. Add a numeric index as a suffix
296 296
                 # so that the inputs don't all have the same ID attribute.
297 297
                 input_attrs['id'] = '%s_%s' % (id_, i)
298  
-            inputs.append(format_html('<input{} />', flatatt(input_attrs)))
  298
+            inputs.append(format_html('<input{0} />', flatatt(input_attrs)))
299 299
         return mark_safe('\n'.join(inputs))
300 300
 
301 301
     def value_from_datadict(self, data, files, name):
@@ -512,7 +512,7 @@ def render(self, name, value, attrs=None):
512 512
         if not (value is True or value is False or value is None or value == ''):
513 513
             # Only add the 'value' attribute if a value is non-empty.
514 514
             final_attrs['value'] = force_unicode(value)
515  
-        return format_html('<input{} />', flatatt(final_attrs))
  515
+        return format_html('<input{0} />', flatatt(final_attrs))
516 516
 
517 517
     def value_from_datadict(self, data, files, name):
518 518
         if name not in data:
@@ -544,7 +544,7 @@ def __init__(self, attrs=None, choices=()):
544 544
     def render(self, name, value, attrs=None, choices=()):
545 545
         if value is None: value = ''
546 546
         final_attrs = self.build_attrs(attrs, name=name)
547  
-        output = [format_html('<select{}>', flatatt(final_attrs))]
  547
+        output = [format_html('<select{0}>', flatatt(final_attrs))]
548 548
         options = self.render_options(choices, [value])
549 549
         if options:
550 550
             output.append(options)
@@ -620,7 +620,7 @@ class SelectMultiple(Select):
620 620
     def render(self, name, value, attrs=None, choices=()):
621 621
         if value is None: value = []
622 622
         final_attrs = self.build_attrs(attrs, name=name)
623  
-        output = [format_html('<select multiple="multiple"{}>', flatatt(final_attrs))]
  623
+        output = [format_html('<select multiple="multiple"{0}>', flatatt(final_attrs))]
624 624
         options = self.render_options(choices, value)
625 625
         if options:
626 626
             output.append(options)
@@ -679,7 +679,7 @@ def tag(self):
679 679
         final_attrs = dict(self.attrs, type='radio', name=self.name, value=self.choice_value)
680 680
         if self.is_checked():
681 681
             final_attrs['checked'] = 'checked'
682  
-        return format_html('<input{} />', flatatt(final_attrs))
  682
+        return format_html('<input{0} />', flatatt(final_attrs))
683 683
 
684 684
 class RadioFieldRenderer(StrAndUnicode):
685 685
     """
2  django/template/defaulttags.py
@@ -47,7 +47,7 @@ def render(self, context):
47 47
             if csrf_token == 'NOTPROVIDED':
48 48
                 return format_html("")
49 49
             else:
50  
-                return format_html("<div style='display:none'><input type='hidden' name='csrfmiddlewaretoken' value='{}' /></div>", csrf_token)
  50
+                return format_html("<div style='display:none'><input type='hidden' name='csrfmiddlewaretoken' value='{0}' /></div>", csrf_token)
51 51
         else:
52 52
             # It's very probable that the token is missing because of
53 53
             # misconfiguration, so we raise a warning

0 notes on commit 8fdc56d

Please sign in to comment.
Something went wrong with that request. Please try again.