Currently the identifier tracking is very crude and is based on just prefixing variables. The idea would be to keep some unique variable rewriting into unique identifiers that can be reversed as well.
This should make it unnecessary to use locals() all over the code and fix some problems with identifiers over function boundaries.
How do you know you are affected by this issue? You get something along the lines of "Unbound variable l_SOMETHING" found.
From #pocoo just now:
magicbronson: hey mitsuhiko et al., trying to render a Jinja template in a Flask app and getting a very mysterious message: "global name 'l_config' is not defined"
magicbronson: l_config appears nowhere in my code or libraries'
mitsuhiko: magicbronson: that's the scoping bug that i will fix over this summer
mitsuhiko: {% macro foo() %}{{ config }}{% for config in something_else %}{{config}}{% endfor %}{% endmacro %}
mitsuhiko: something like this triggers the bug currently
mitsuhiko: magicbronson: rename the variable inside of the macro to something else
mitsuhiko: {% set cfg = config %}
mitsuhiko: outside the macro
mitsuhiko: or something
Armin's suggestion worked around the issue.
This is finally done.
Most helpful comment
This is finally done.