Skip to content
Myr

Merge pull request #938 from stevenorum/master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixing compiler handling of parens around boolean comparisons.

authored by David Lord · committed by GitHub · parents c8b1b02, eca6fbf · Browse files · 2 files+8 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+8 added−0 removed

  • tests:+6 added−0 removed
  • other:+2 added−0 removed

2 files+8 added−0 removed

modified:jinja2/compiler.py+2 added
1527 unmodified lines
1528 self.write('))')15291530 @optimizeconst1531 def visit_Compare(self, node, frame):1532 self.write('(')1533 self.visit(node.expr, frame)1534 for op in node.ops:1535 self.visit(op, frame)1536 self.write(')')15371538 def visit_Operand(self, node, frame):1539 self.write(' %s ' % operators[node.op])1540 self.visit(node.expr, frame)
183 unmodified lines
modified:tests/test_lexnparse.py+6 added
330 unmodified lines
331 tmpl = env.from_string('{{ 1 > 0 }}|{{ 1 >= 1 }}|{{ 2 < 3 }}|'332 '{{ 2 == 2 }}|{{ 1 <= 1 }}')333 assert tmpl.render() == 'True|True|True|True|True'334335 def test_compare_parens(self, env):336 tmpl = env.from_string(337 "{{ i*(j<5) }}"338 )339 assert tmpl.render(i=2, j=3) == '2'340341 def test_inop(self, env):342 tmpl = env.from_string('{{ 1 in [1, 2, 3] }}|{{ 1 not in [1, 2, 3] }}')343 assert tmpl.render() == 'True|False'344
349 unmodified lines