Fixed a typo in the docs
[jinja2.git] / custom_fixers / fix_broken_reraising.py
1 from lib2to3 import fixer_base, pytree
2 from lib2to3.fixer_util import Name, BlankLine, Name, Attr, ArgList
3
4
5 class FixBrokenReraising(fixer_base.BaseFix):
6     PATTERN = """
7     raise_stmt< 'raise' any ',' val=any ',' tb=any >
8     """
9
10     # run before the broken 2to3 checker with the same goal
11     # tries to rewrite it with a rule that does not work out for jinja
12     run_order = 1
13
14     def transform(self, node, results):
15         tb = results['tb'].clone()
16         tb.prefix = ''
17         with_tb = Attr(results['val'].clone(), Name('with_traceback')) + \
18                   [ArgList([tb])]
19         new = pytree.Node(self.syms.simple_stmt, [Name("raise")] + with_tb)
20         new.prefix = node.prefix
21         return new