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

« back to all changes in this revision

Viewing changes to Lib/lib2to3/fixes/fix_execfile.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:
31
31
        execfile_paren = node.children[-1].children[-1].clone()
32
32
        # Construct open().read().
33
33
        open_args = ArgList([filename.clone()], rparen=execfile_paren)
34
 
        open_call = Node(syms.power, [Name("open"), open_args])
35
 
        read = [Node(syms.trailer, [Dot(), Name('read')]),
 
34
        open_call = Node(syms.power, [Name(u"open"), open_args])
 
35
        read = [Node(syms.trailer, [Dot(), Name(u'read')]),
36
36
                Node(syms.trailer, [LParen(), RParen()])]
37
37
        open_expr = [open_call] + read
38
38
        # Wrap the open call in a compile call. This is so the filename will be
39
39
        # preserved in the execed code.
40
40
        filename_arg = filename.clone()
41
 
        filename_arg.set_prefix(" ")
42
 
        exec_str = String("'exec'", " ")
 
41
        filename_arg.prefix = u" "
 
42
        exec_str = String(u"'exec'", u" ")
43
43
        compile_args = open_expr + [Comma(), filename_arg, Comma(), exec_str]
44
 
        compile_call = Call(Name("compile"), compile_args, "")
 
44
        compile_call = Call(Name(u"compile"), compile_args, u"")
45
45
        # Finally, replace the execfile call with an exec call.
46
46
        args = [compile_call]
47
47
        if globals is not None:
48
48
            args.extend([Comma(), globals.clone()])
49
49
        if locals is not None:
50
50
            args.extend([Comma(), locals.clone()])
51
 
        return Call(Name("exec"), args, prefix=node.get_prefix())
 
51
        return Call(Name(u"exec"), args, prefix=node.prefix)