Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 22 lines (17 sloc) 0.72 kb
0d242be Armin Ronacher Down to 7 failures for Python 3. We're onto something.
authored
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
Something went wrong with that request. Please try again.