Attempt 2: Catch errors getting filters and tests (#76806)

pull/76810/head
Matt Martz 4 years ago committed by GitHub
parent 374720fc97
commit 9f46f6eb30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
bugfixes:
- Templating - Ensure we catch exceptions when getting ``.filters`` and
``.tests`` attributes on their respective plugins and properly error,
instead of aborting which results in no filters being added to the
jinja2 environment

@ -546,9 +546,8 @@ class JinjaPluginIntercept(MutableMapping):
except Exception as e:
raise TemplateSyntaxError(to_native(e), 0)
method_map = getattr(plugin_impl, self._method_map_name)
try:
method_map = getattr(plugin_impl, self._method_map_name)
func_items = method_map().items()
except Exception as e:
display.warning(

@ -0,0 +1,10 @@
# Copyright (c) 2021 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
class FilterModule:
pass

@ -17,6 +17,8 @@
- |
result.stderr|regex_findall('bad_test')|length == 2
- |
result.stderr|regex_findall('bad_collection_filter')|length == 2
result.stderr|regex_findall('bad_collection_filter')|length == 3
- |
result.stderr|regex_findall('bad_collection_filter2')|length == 1
- |
result.stderr|regex_findall('bad_collection_test')|length == 2

Loading…
Cancel
Save