Skip to content

Bug with right-left associativity of exponent #1722

@krepysh

Description

@krepysh

Discovered it when working on #1720. Looks like the fix will fix both issues.

Minimal reproducible example

from jinja2 import Environment
env = Environment()
tmpl = env.from_string('{{ 2 ** 3 ** 2 }}')
assert eval('2 ** 3 ** 2') == 512 
assert tmpl.render() == '512' # it's actualy 64 because of wrong order

Expected behaviour

I expected exact behaviour as in pure python. We need to start evaluation from left to right.

Environment:

  • Python version: 3.9.12
  • Jinja version: 3.1.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions