From: Mark Dickinson Date: Mon, 28 Jun 2010 19:54:19 +0000 (+0000) Subject: unparse.py: fix mispaced parentheses in chained comparisons X-Git-Tag: v2.7~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0187be082562471206fc0e7ee7231ecad591ab19;p=python unparse.py: fix mispaced parentheses in chained comparisons --- diff --git a/Demo/parser/test_unparse.py b/Demo/parser/test_unparse.py index 4f3a28e52b..857b999829 100644 --- a/Demo/parser/test_unparse.py +++ b/Demo/parser/test_unparse.py @@ -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) diff --git a/Demo/parser/unparse.py b/Demo/parser/unparse.py index d48ddd1b28..98aeb32d57 100644 --- a/Demo/parser/unparse.py +++ b/Demo/parser/unparse.py @@ -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):