salt-common Jinja utils not compatible with installed jinja2

Bug #1977552 reported by Nick Porter
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
salt (Ubuntu)
New
Undecided
Unassigned

Bug Description

/usr/lib/python3/dist-packages/salt/utils/jinja.py attempts to import Markup from jinja2. That is not available in the version of jinja2 installed.

In addition it calls jinja2.contextfunction which is no-longer available.

/salt/utils/jinja.py on SaltStack's github repo has the relevant fixes:

replacing

from jinja2 import BaseLoader, Markup, TemplateNotFound, nodes

with

from jinja2 import BaseLoader, TemplateNotFound, nodes

try:
    from markupsafe import Markup
except ImportError:
    # jinja < 3.1
    from jinja2 import Markup

and

replacing

@jinja2.contextfunction
def show_full_context(ctx):
    return salt.utils.data.simple_types_filter(
        {key: value for key, value in ctx.items()}
    )

with

try:
    contextfunction = jinja2.contextfunction
except AttributeError:
    contextfunction = jinja2.pass_context

@contextfunction
def show_full_context(ctx):
    return salt.utils.data.simple_types_filter(
        {key: value for key, value in ctx.items()}
    )

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.