From: Kevin Brown Date: Fri, 15 May 2020 00:04:57 +0000 (-0400) Subject: Fix handling of tests which check constants X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=23a145dc2d7cfdd73c4c7022e0d620bfcd27e8fb;p=thirdparty%2Fjinja.git Fix handling of tests which check constants Because of how the parser works, it does not differentiate between constants and function names, so this needs to convert it back. --- diff --git a/src/jinja2/new_parser.py b/src/jinja2/new_parser.py index b0cba654..ea34f9bb 100644 --- a/src/jinja2/new_parser.py +++ b/src/jinja2/new_parser.py @@ -558,6 +558,14 @@ def parse_conditional_expression_test(ast): kwargs = call.kwargs dynamic_args = call.dyn_args dynamic_kwargs = call.dyn_kwargs + elif isinstance(test_function, nodes.Const): + const_map = { + None: 'none', + True: 'true', + False: 'false', + } + + name = const_map[test_function.value] else: name = test_function.name