Commits

Anonymous committed 95805f4

Changed 'raise' statements to new style syntax in documentation. Thanks DaNmarner. Refs #15635.

  • Participants
  • Parent commits 08ac35a

Comments (0)

Files changed (3)

File docs/howto/custom-template-tags.txt

             # split_contents() knows not to split quoted strings.
             tag_name, format_string = token.split_contents()
         except ValueError:
-            raise template.TemplateSyntaxError, "%r tag requires a single argument" % token.contents.split()[0]
+            raise template.TemplateSyntaxError("%r tag requires a single argument" % token.contents.split()[0])
         if not (format_string[0] == format_string[-1] and format_string[0] in ('"', "'")):
-            raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name
+            raise template.TemplateSyntaxError("%r tag's argument should be in quotes" % tag_name)
         return CurrentTimeNode(format_string[1:-1])
 
 Notes:
             # split_contents() knows not to split quoted strings.
             tag_name, date_to_be_formatted, format_string = token.split_contents()
         except ValueError:
-            raise template.TemplateSyntaxError, "%r tag requires exactly two arguments" % token.contents.split()[0]
+            raise template.TemplateSyntaxError("%r tag requires exactly two arguments" % token.contents.split()[0])
         if not (format_string[0] == format_string[-1] and format_string[0] in ('"', "'")):
-            raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name
+            raise template.TemplateSyntaxError("%r tag's argument should be in quotes" % tag_name)
         return FormatTimeNode(date_to_be_formatted, format_string[1:-1])
 
 You also have to change the renderer to retrieve the actual contents of the
             # Splitting by None == splitting by spaces.
             tag_name, arg = token.contents.split(None, 1)
         except ValueError:
-            raise template.TemplateSyntaxError, "%r tag requires arguments" % token.contents.split()[0]
+            raise template.TemplateSyntaxError("%r tag requires arguments" % token.contents.split()[0])
         m = re.search(r'(.*?) as (\w+)', arg)
         if not m:
-            raise template.TemplateSyntaxError, "%r tag had invalid arguments" % tag_name
+            raise template.TemplateSyntaxError("%r tag had invalid arguments" % tag_name)
         format_string, var_name = m.groups()
         if not (format_string[0] == format_string[-1] and format_string[0] in ('"', "'")):
-            raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name
+            raise template.TemplateSyntaxError("%r tag's argument should be in quotes" % tag_name)
         return CurrentTimeNode3(format_string[1:-1], var_name)
 
 The difference here is that ``do_current_time()`` grabs the format string and

File docs/ref/templates/api.txt

         >>> t = Template("My name is {{ person.first_name }}.")
         >>> class PersonClass3:
         ...     def first_name(self):
-        ...         raise AssertionError, "foo"
+        ...         raise AssertionError("foo")
         >>> p = PersonClass3()
         >>> t.render(Context({"person": p}))
         Traceback (most recent call last):

File docs/topics/forms/formsets.txt

     ...             form = self.forms[i]
     ...             title = form.cleaned_data['title']
     ...             if title in titles:
-    ...                 raise forms.ValidationError, "Articles in a set must have distinct titles."
+    ...                 raise forms.ValidationError("Articles in a set must have distinct titles.")
     ...             titles.append(title)
 
     >>> ArticleFormSet = formset_factory(ArticleForm, formset=BaseArticleFormSet)