[Python-checkins] r58056 - in sandbox/trunk/2to3: fixes/fix_tuple_params.py tests/test_fixers.py
collin.winter
python-checkins at python.org
Sat Sep 8 23:12:46 CEST 2007
Author: collin.winter
Date: Sat Sep 8 23:12:45 2007
New Revision: 58056
Modified:
sandbox/trunk/2to3/fixes/fix_tuple_params.py
sandbox/trunk/2to3/tests/test_fixers.py
Log:
Fix a prefix-related bug in fix_tuple_params lambda-handling code.
Modified: sandbox/trunk/2to3/fixes/fix_tuple_params.py
==============================================================================
--- sandbox/trunk/2to3/fixes/fix_tuple_params.py (original)
+++ sandbox/trunk/2to3/fixes/fix_tuple_params.py Sat Sep 8 23:12:45 2007
@@ -109,7 +109,7 @@
# Replace lambda ((((x)))): x with lambda x: x
if inner.type == token.NAME:
inner = inner.clone()
- inner.set_prefix(args.get_prefix())
+ inner.set_prefix(" ")
args.replace(inner)
return
@@ -117,8 +117,7 @@
to_index = map_to_index(params)
tup_name = self.new_name(tuple_name(params))
- new_param = Name(tup_name)
- new_param.set_prefix(args.get_prefix())
+ new_param = Name(tup_name, prefix=" ")
args.replace(new_param.clone())
for n in body.post_order():
if n.type == token.NAME and n.value in to_index:
Modified: sandbox/trunk/2to3/tests/test_fixers.py
==============================================================================
--- sandbox/trunk/2to3/tests/test_fixers.py (original)
+++ sandbox/trunk/2to3/tests/test_fixers.py Sat Sep 8 23:12:45 2007
@@ -1536,19 +1536,35 @@
a = """lambda x: x + 5"""
self.check(b, a)
+ b = """lambda(x): x + 5"""
+ a = """lambda x: x + 5"""
+ self.check(b, a)
+
b = """lambda ((((x)))): x + 5"""
a = """lambda x: x + 5"""
self.check(b, a)
+ b = """lambda((((x)))): x + 5"""
+ a = """lambda x: x + 5"""
+ self.check(b, a)
+
def test_lambda_simple(self):
b = """lambda (x, y): x + f(y)"""
a = """lambda x_y: x_y[0] + f(x_y[1])"""
self.check(b, a)
+ b = """lambda(x, y): x + f(y)"""
+ a = """lambda x_y: x_y[0] + f(x_y[1])"""
+ self.check(b, a)
+
b = """lambda (((x, y))): x + f(y)"""
a = """lambda x_y: x_y[0] + f(x_y[1])"""
self.check(b, a)
+ b = """lambda(((x, y))): x + f(y)"""
+ a = """lambda x_y: x_y[0] + f(x_y[1])"""
+ self.check(b, a)
+
def test_lambda_one_tuple(self):
b = """lambda (x,): x + f(x)"""
a = """lambda x1: x1[0] + f(x1[0])"""
More information about the Python-checkins
mailing list