]> granicus.if.org Git - python/commitdiff
unparse.py: fix mispaced parentheses in chained comparisons
authorMark Dickinson <dickinsm@gmail.com>
Mon, 28 Jun 2010 19:54:19 +0000 (19:54 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Mon, 28 Jun 2010 19:54:19 +0000 (19:54 +0000)
Demo/parser/test_unparse.py
Demo/parser/unparse.py

index 4f3a28e52b2752c7803b288b5ef030378ac780c7..857b9998294bc43018a5381c6195ee813ef785cb 100644 (file)
@@ -53,6 +53,10 @@ class UnparseTestCase(unittest.TestCase):
         self.check_roundtrip("not True or False")
         self.check_roundtrip("True or not False")
 
+    def test_chained_comparisons(self):
+        self.check_roundtrip("1 < 4 <= 5")
+        self.check_roundtrip("a is b is c is not d")
+
 
 def test_main():
     test_support.run_unittest(UnparseTestCase)
index d48ddd1b2832b3633452511a84452c9047781302..98aeb32d575b6b8237fb4963ed370cd1b6d2c5fa 100644 (file)
@@ -388,7 +388,7 @@ class Unparser:
         for o, e in zip(t.ops, t.comparators):
             self.write(" " + self.cmpops[o.__class__.__name__] + " ")
             self.dispatch(e)
-            self.write(")")
+        self.write(")")
 
     boolops = {_ast.And: 'and', _ast.Or: 'or'}
     def _BoolOp(self, t):