[Python-checkins] r56428 - in sandbox/trunk/2to3: fixes/util.py tests/test_util.py

collin.winter python-checkins at python.org
Tue Jul 17 23:11:56 CEST 2007


Author: collin.winter
Date: Tue Jul 17 23:11:55 2007
New Revision: 56428

Modified:
   sandbox/trunk/2to3/   (props changed)
   sandbox/trunk/2to3/fixes/util.py
   sandbox/trunk/2to3/tests/test_util.py
Log:
Make is_tuple() recognize empty tuple literals.


Modified: sandbox/trunk/2to3/fixes/util.py
==============================================================================
--- sandbox/trunk/2to3/fixes/util.py	(original)
+++ sandbox/trunk/2to3/fixes/util.py	Tue Jul 17 23:11:55 2007
@@ -109,6 +109,8 @@
 
 def is_tuple(node):
     """Does the node represent a tuple literal?"""
+    if isinstance(node, Node) and node.children == [LParen(), RParen()]:
+        return True
     return (isinstance(node, Node)
             and len(node.children) == 3
             and isinstance(node.children[0], Leaf)

Modified: sandbox/trunk/2to3/tests/test_util.py
==============================================================================
--- sandbox/trunk/2to3/tests/test_util.py	(original)
+++ sandbox/trunk/2to3/tests/test_util.py	Tue Jul 17 23:11:55 2007
@@ -38,6 +38,7 @@
         self.failUnless(self.is_tuple("(a, (b, c))"))
         self.failUnless(self.is_tuple("((a, (b, c)),)"))
         self.failUnless(self.is_tuple("(a,)"))
+        self.failUnless(self.is_tuple("()"))
     
     def test_invalid(self):
         self.failIf(self.is_tuple("(a)"))


More information about the Python-checkins mailing list