- Added support for Python 3.6 async iterators through a new async mode.
- Added policies for filter defaults and similar things.
- urlize now sets "rel noopener" by default.
+- Support attribute fallback for old-style classes in 2.x.
Version 2.8.2
-------------
"""Get an item or attribute of an object but prefer the item."""
try:
return obj[argument]
- except (TypeError, LookupError):
+ except (AttributeError, TypeError, LookupError):
if isinstance(argument, string_types):
try:
attr = str(argument)
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
+import sys
import pytest
from jinja2 import Template, Environment, DictLoader, TemplateSyntaxError, \
expected = 'TEST'
assert output == expected
+
+ @pytest.mark.skipif(sys.version_info[0] > 2,
+ reason='This only works on 2.x')
+ def test_old_style_attribute(self, env):
+ class Foo:
+ x = 42
+ assert env.getitem(Foo(), 'x') == 42