Skip to content

Commit

Permalink
Templar: do not add dict to globals (ansible#80475)
Browse files Browse the repository at this point in the history
All required Jinja2 versions (>=3.0) already do this, see
pallets/jinja@f9d804e
  • Loading branch information
mkrizek authored Apr 11, 2023
1 parent 4e9d21e commit 5ddd530
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/templar-globals-dict.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- "``Templar`` - do not add the ``dict`` constructor to ``globals`` as all required Jinja2 versions already do so"
5 changes: 1 addition & 4 deletions lib/ansible/template/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
AnsibleOptionsError,
AnsibleUndefinedVariable,
)
from ansible.module_utils.six import string_types, text_type
from ansible.module_utils.six import string_types
from ansible.module_utils._text import to_native, to_text, to_bytes
from ansible.module_utils.common.collections import is_sequence
from ansible.plugins.loader import filter_loader, lookup_loader, test_loader
Expand Down Expand Up @@ -566,9 +566,6 @@ def __init__(self, loader, shared_loader_obj=None, variables=None):
)
self.environment.template_class.environment_class = environment_class

# jinja2 global is inconsistent across versions, this normalizes them
self.environment.globals['dict'] = dict

# Custom globals
self.environment.globals['lookup'] = self._lookup
self.environment.globals['query'] = self.environment.globals['q'] = self._query_lookup
Expand Down

0 comments on commit 5ddd530

Please sign in to comment.