[Python-checkins] r57514 - in sandbox/trunk/2to3: fixes/fix_type_equality.py tests/test_fixers.py
collin.winter
python-checkins at python.org
Sun Aug 26 21:43:04 CEST 2007
Author: collin.winter
Date: Sun Aug 26 21:43:03 2007
New Revision: 57514
Modified:
sandbox/trunk/2to3/ (props changed)
sandbox/trunk/2to3/fixes/fix_type_equality.py
sandbox/trunk/2to3/tests/test_fixers.py
Log:
Fix a prefix-related bug in fix_type_equality.
Modified: sandbox/trunk/2to3/fixes/fix_type_equality.py
==============================================================================
--- sandbox/trunk/2to3/fixes/fix_type_equality.py (original)
+++ sandbox/trunk/2to3/fixes/fix_type_equality.py Sun Aug 26 21:43:03 2007
@@ -18,4 +18,5 @@
T = results['T'].clone() # The type being compared against
x.set_prefix('')
T.set_prefix(' ')
- return Call(Name('isinstance'), [x, Comma(), T])
+ return Call(Name('isinstance', prefix=node.get_prefix()),
+ [x, Comma(), T])
Modified: sandbox/trunk/2to3/tests/test_fixers.py
==============================================================================
--- sandbox/trunk/2to3/tests/test_fixers.py (original)
+++ sandbox/trunk/2to3/tests/test_fixers.py Sun Aug 26 21:43:03 2007
@@ -2356,11 +2356,19 @@
a = """isinstance(x, T)"""
self.check(b, a)
+ b = """if type(x) == T: pass"""
+ a = """if isinstance(x, T): pass"""
+ self.check(b, a)
+
def test_reverse(self):
b = """T == type(x)"""
a = """isinstance(x, T)"""
self.check(b, a)
+ b = """if T == type(x): pass"""
+ a = """if isinstance(x, T): pass"""
+ self.check(b, a)
+
def test_expression(self):
b = """type(x+y) == d.get('T')"""
a = """isinstance(x+y, d.get('T'))"""
More information about the Python-checkins
mailing list