[Python-checkins] r56420 - in sandbox/trunk/2to3: fixes/fix_apply.py fixes/fix_callable.py fixes/fix_exec.py fixes/fix_input.py fixes/fix_print.py fixes/fix_repr.py fixes/util.py
collin.winter
python-checkins at python.org
Tue Jul 17 23:09:53 CEST 2007
Author: collin.winter
Date: Tue Jul 17 23:09:52 2007
New Revision: 56420
Modified:
sandbox/trunk/2to3/ (props changed)
sandbox/trunk/2to3/fixes/fix_apply.py
sandbox/trunk/2to3/fixes/fix_callable.py
sandbox/trunk/2to3/fixes/fix_exec.py
sandbox/trunk/2to3/fixes/fix_input.py
sandbox/trunk/2to3/fixes/fix_print.py
sandbox/trunk/2to3/fixes/fix_repr.py
sandbox/trunk/2to3/fixes/util.py
Log:
Add a prefix keyword arg to Call() and make use of it.
Modified: sandbox/trunk/2to3/fixes/fix_apply.py
==============================================================================
--- sandbox/trunk/2to3/fixes/fix_apply.py (original)
+++ sandbox/trunk/2to3/fixes/fix_apply.py Tue Jul 17 23:09:52 2007
@@ -55,6 +55,4 @@
# XXX Sometimes we could be cleverer, e.g. apply(f, (x, y) + t)
# can be translated into f(x, y, *t) instead of f(*(x, y) + t)
#new = pytree.Node(syms.power, (func, ArgList(l_newargs)))
- new = Call(func, l_newargs)
- new.set_prefix(prefix)
- return new
+ return Call(func, l_newargs, prefix=prefix)
Modified: sandbox/trunk/2to3/fixes/fix_callable.py
==============================================================================
--- sandbox/trunk/2to3/fixes/fix_callable.py (original)
+++ sandbox/trunk/2to3/fixes/fix_callable.py Tue Jul 17 23:09:52 2007
@@ -28,7 +28,4 @@
func = results["func"]
args = [func.clone(), String(', '), String("'__call__'")]
- new = Call(Name("hasattr"), args)
- new.set_prefix(node.get_prefix())
- return new
-
+ return Call(Name("hasattr"), args, prefix=node.get_prefix())
Modified: sandbox/trunk/2to3/fixes/fix_exec.py
==============================================================================
--- sandbox/trunk/2to3/fixes/fix_exec.py (original)
+++ sandbox/trunk/2to3/fixes/fix_exec.py Tue Jul 17 23:09:52 2007
@@ -36,6 +36,4 @@
if c is not None:
args.extend([Comma(), c.clone()])
- new = Call(Name("exec"), args)
- new.set_prefix(node.get_prefix())
- return new
+ return Call(Name("exec"), args, prefix=node.get_prefix())
Modified: sandbox/trunk/2to3/fixes/fix_input.py
==============================================================================
--- sandbox/trunk/2to3/fixes/fix_input.py (original)
+++ sandbox/trunk/2to3/fixes/fix_input.py Tue Jul 17 23:09:52 2007
@@ -17,6 +17,4 @@
def transform(self, node, results):
new = node.clone()
new.set_prefix("")
- new = Call(Name("eval"), [new])
- new.set_prefix(node.get_prefix())
- return new
+ return Call(Name("eval"), [new], prefix=node.get_prefix())
Modified: sandbox/trunk/2to3/fixes/fix_print.py
==============================================================================
--- sandbox/trunk/2to3/fixes/fix_print.py (original)
+++ sandbox/trunk/2to3/fixes/fix_print.py Tue Jul 17 23:09:52 2007
@@ -36,9 +36,7 @@
if node == Name("print"):
# Special-case print all by itself
- new = Call(Name("print"), [])
- new.set_prefix(node.get_prefix())
- return new
+ return Call(Name("print"), [], prefix=node.get_prefix())
assert node.children[0] == Name("print")
args = node.children[1:]
sep = end = file = None
Modified: sandbox/trunk/2to3/fixes/fix_repr.py
==============================================================================
--- sandbox/trunk/2to3/fixes/fix_repr.py (original)
+++ sandbox/trunk/2to3/fixes/fix_repr.py Tue Jul 17 23:09:52 2007
@@ -19,6 +19,4 @@
if expr.type == self.syms.testlist1:
expr = self.parenthesize(expr)
- new = Call(Name("repr"), [expr])
- new.set_prefix(node.get_prefix())
- return new
+ return Call(Name("repr"), [expr], prefix=node.get_prefix())
Modified: sandbox/trunk/2to3/fixes/util.py
==============================================================================
--- sandbox/trunk/2to3/fixes/util.py (original)
+++ sandbox/trunk/2to3/fixes/util.py Tue Jul 17 23:09:52 2007
@@ -55,9 +55,12 @@
Node(syms.arglist, args),
rparen.clone()])
-def Call(func_name, args):
+def Call(func_name, args, prefix=None):
"""A function call"""
- return Node(syms.power, [func_name, ArgList(args)])
+ node = Node(syms.power, [func_name, ArgList(args)])
+ if prefix is not None:
+ node.set_prefix(prefix)
+ return node
def Newline():
"""A newline literal"""
More information about the Python-checkins
mailing list