[Python-checkins] r76061 - in sandbox/trunk/2to3/lib2to3: fixes/fix_tuple_params.py tests/test_fixers.py
benjamin.peterson
python-checkins at python.org
Mon Nov 2 19:06:17 CET 2009
Author: benjamin.peterson
Date: Mon Nov 2 19:06:17 2009
New Revision: 76061
Log:
make fix_tuple_params keep the tree valid #7253
Modified:
sandbox/trunk/2to3/lib2to3/fixes/fix_tuple_params.py
sandbox/trunk/2to3/lib2to3/tests/test_fixers.py
Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_tuple_params.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/fixes/fix_tuple_params.py (original)
+++ sandbox/trunk/2to3/lib2to3/fixes/fix_tuple_params.py Mon Nov 2 19:06:17 2009
@@ -96,6 +96,8 @@
new_lines[0].prefix = indent
after = start + 1
+ for line in new_lines:
+ line.parent = suite[0]
suite[0].children[after:after] = new_lines
for i in range(after+1, after+len(new_lines)+1):
suite[0].children[i].prefix = indent
Modified: sandbox/trunk/2to3/lib2to3/tests/test_fixers.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/tests/test_fixers.py (original)
+++ sandbox/trunk/2to3/lib2to3/tests/test_fixers.py Mon Nov 2 19:06:17 2009
@@ -339,6 +339,12 @@
a = "from functools import reduce\nreduce(a, b, c)"
self.check(b, a)
+ def test_bug_7253(self):
+ # fix_tuple_params was being bad and orphaning nodes in the tree.
+ b = "def x(arg): reduce(sum, [])"
+ a = "from functools import reduce\ndef x(arg): reduce(sum, [])"
+ self.check(b, a)
+
def test_call_with_lambda(self):
b = "reduce(lambda x, y: x + y, seq)"
a = "from functools import reduce\nreduce(lambda x, y: x + y, seq)"
More information about the Python-checkins
mailing list