[Python-checkins] r54578 - in sandbox/trunk/2to3: fixes/util.py tests/test_util.py
collin.winter
python-checkins at python.org
Mon Mar 26 18:45:06 CEST 2007
Author: collin.winter
Date: Mon Mar 26 18:45:01 2007
New Revision: 54578
Modified:
sandbox/trunk/2to3/fixes/util.py
sandbox/trunk/2to3/tests/test_util.py
Log:
Add while and if suite support to find_binding.
Modified: sandbox/trunk/2to3/fixes/util.py
==============================================================================
--- sandbox/trunk/2to3/fixes/util.py (original)
+++ sandbox/trunk/2to3/fixes/util.py Mon Mar 26 18:45:01 2007
@@ -125,6 +125,9 @@
return child
elif _find(name, child.children[-1]):
return child
+ elif child.type in (syms.if_stmt, syms.while_stmt):
+ if _find(name, child.children[-1]):
+ return child
elif child.type in _def_syms and child.children[1].value == name:
return child
elif _is_import_binding(child, name):
Modified: sandbox/trunk/2to3/tests/test_util.py
==============================================================================
--- sandbox/trunk/2to3/tests/test_util.py (original)
+++ sandbox/trunk/2to3/tests/test_util.py Mon Mar 26 18:45:01 2007
@@ -177,6 +177,14 @@
self.failUnless(self.find_binding("a", "for c, (a, b) in r: pass"))
self.failUnless(self.find_binding("a", "for c in r: a = c"))
+ def test_if(self):
+ self.failUnless(self.find_binding("a", "if b in r: a = c"))
+ self.failIf(self.find_binding("a", "if a in r: d = e"))
+
+ def test_while(self):
+ self.failUnless(self.find_binding("a", "while b in r: a = c"))
+ self.failIf(self.find_binding("a", "while a in r: d = e"))
+
if __name__ == "__main__":
import __main__
More information about the Python-checkins
mailing list