1 from lib2to3 import fixer_base, pytree
2 from lib2to3.fixer_util import Name, BlankLine, Name, Attr, ArgList
5 class FixBrokenReraising(fixer_base.BaseFix):
7 raise_stmt< 'raise' any ',' val=any ',' tb=any >
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
14 def transform(self, node, results):
15 tb = results['tb'].clone()
17 with_tb = Attr(results['val'].clone(), Name('with_traceback')) + \
19 new = pytree.Node(self.syms.simple_stmt, [Name("raise")] + with_tb)
20 new.prefix = node.prefix