From: David Lord Date: Thu, 27 Feb 2020 19:16:01 +0000 (-0800) Subject: Merge branch '2.11.x' X-Git-Tag: 3.0.0rc1~116 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45a76a3794a91e6d7077ced88c814a96cc87d5c2;p=thirdparty%2Fjinja.git Merge branch '2.11.x' --- 45a76a3794a91e6d7077ced88c814a96cc87d5c2 diff --cc CHANGES.rst index 20358b6f,9635fc55..e7542118 --- a/CHANGES.rst +++ b/CHANGES.rst @@@ -19,7 -8,9 +19,8 @@@ Unrelease - Fix a bug that caused callable objects with ``__getattr__``, like :class:`~unittest.mock.Mock` to be treated as a :func:`contextfunction`. :issue:`1145` - + - Update ``wordcount`` filter to trigger :class:`Undefined` methods - by wrapping the input in :func:`soft_unicode`. :pr:`1160` - ++ by wrapping the input in :func:`soft_str`. :pr:`1160` Version 2.11.1 -------------- diff --cc src/jinja2/filters.py index f39d389f,97415673..c257d4c5 --- a/src/jinja2/filters.py +++ b/src/jinja2/filters.py @@@ -741,7 -761,7 +741,7 @@@ def do_wordwrap def do_wordcount(s): """Count the words in that string.""" - return len(_word_re.findall(s)) - return len(_word_re.findall(soft_unicode(s))) ++ return len(_word_re.findall(soft_str(s))) def do_int(value, default=0, base=10): diff --cc tests/test_filters.py index ab6e93d4,388c3462..8087a248 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@@ -5,9 -6,14 +5,11 @@@ import pytes from jinja2 import Environment from jinja2 import Markup + from jinja2 import StrictUndefined + from jinja2 import UndefinedError -from jinja2._compat import implements_to_string -from jinja2._compat import text_type -@implements_to_string -class Magic(object): +class Magic: def __init__(self, value): self.value = value