Skip to content
Myr

Broke a test for 2.x :)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent eb43b12 · Browse files · 3 files+3 added−42 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+3 added−42 removed

  • other:+3 added−42 removed

3 files+3 added−42 removed

modified:jinja2/testsuite/debug.py+1 added-2 removed
36 unmodified lines
37 # what's up with that, but that is not that critical. Should38 # be fixed though.39 self.assert_traceback_matches(lambda: env.get_template('syntaxerror.html'), r'''(?sm)40 File ".*?syntaxerror.html", line 4, in (template|<module>)41 \{% endif %\}42 .*?41 \{% endif %\}.*?42(jinja2\.exceptions\.)?TemplateSyntaxError: Encountered unknown tag 'endif'. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.43 ''')4445 def test_regular_syntax_error(self):
13 unmodified lines
modified:MANIFEST.in+2 added-1 removed
1include MANIFEST.in Makefile CHANGES LICENSE AUTHORS TODO ez_setup.py1include MANIFEST.in Makefile CHANGES LICENSE AUTHORS2recursive-include docs *3recursive-include custom_fixers *4recursive-include tests *5recursive-include ext *6recursive-include artwork *7recursive-include examples *
2 unmodified lines
deleted:TODO-39 removed
1Todo Before Release2===================34This has to be implemented before the release:56Pull Attributes Onces7---------------------89Imagine the following template::1011 {% if foo.bar %}12 {{ baz(foo.bar) }}13 {% endif %}1415Problem with that is that it compiles to this::1617 if environment.subscribe(l_foo, 'bar'):18 if 0: yield None19 yield u'\n %s\n' % (20 l_baz(environment.subscribe(l_foo, 'bar')),21 )2223As `environment.subscribe` is more expensive then regular attribute lookups24(it tries getitem/getattr and in sandbox mode also permissions) multiple25lookups with the same parameters in the same scope should get local aliases.26The result we have is that one::2728 t1 = environment.subscribe(l_foo, 'bar')29 if t1:30 if 0: yield None31 yield u'\n %s\n' % (32 l_baz(t1),33 )3435However that should only happen if the attribute is accessed multiple times36unlike locals and filters/tests which are always pulled. We're not doing that37for filters/tests/locals as nested scopes may access it and testing is too38complicated for the tiny performance improvement but easy for attribute39lookups, keeping the complexity of the whole thing in mind.