~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Lib/lib2to3/fixes/fix_raise.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
                # exc.children[1:-1] is the unparenthesized tuple
53
53
                # exc.children[1].children[0] is the first element of the tuple
54
54
                exc = exc.children[1].children[0].clone()
55
 
            exc.set_prefix(" ")
 
55
            exc.prefix = " "
56
56
 
57
57
        if "val" not in results:
58
58
            # One-argument raise
59
 
            new = pytree.Node(syms.raise_stmt, [Name("raise"), exc])
60
 
            new.set_prefix(node.get_prefix())
 
59
            new = pytree.Node(syms.raise_stmt, [Name(u"raise"), exc])
 
60
            new.prefix = node.prefix
61
61
            return new
62
62
 
63
63
        val = results["val"].clone()
64
64
        if is_tuple(val):
65
65
            args = [c.clone() for c in val.children[1:-1]]
66
66
        else:
67
 
            val.set_prefix("")
 
67
            val.prefix = u""
68
68
            args = [val]
69
69
 
70
70
        if "tb" in results:
71
71
            tb = results["tb"].clone()
72
 
            tb.set_prefix("")
 
72
            tb.prefix = u""
73
73
 
74
74
            e = Call(exc, args)
75
 
            with_tb = Attr(e, Name('with_traceback')) + [ArgList([tb])]
76
 
            new = pytree.Node(syms.simple_stmt, [Name("raise")] + with_tb)
77
 
            new.set_prefix(node.get_prefix())
 
75
            with_tb = Attr(e, Name(u'with_traceback')) + [ArgList([tb])]
 
76
            new = pytree.Node(syms.simple_stmt, [Name(u"raise")] + with_tb)
 
77
            new.prefix = node.prefix
78
78
            return new
79
79
        else:
80
80
            return pytree.Node(syms.raise_stmt,
81
 
                               [Name("raise"), Call(exc, args)],
82
 
                               prefix=node.get_prefix())
 
81
                               [Name(u"raise"), Call(exc, args)],
 
82
                               prefix=node.prefix)