現在、識別子の追跡は非常に大雑把であり、変数のプレフィックスのみに基づいています。 アイデアは、いくつかの一意の変数を、逆にすることもできる一意の識別子に書き換え続けることです。
これにより、コード全体でlocals()を使用する必要がなくなり、関数の境界を越えた識別子に関するいくつかの問題が修正されます。
この問題の影響を受けていることをどのように知っていますか? 見つかった「非バインド変数l_SOMETHING」の行に沿って何かを取得します。
ちょうど今#pocooから:
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
アーミンの提案はこの問題を回避しました。
これがついに行われます。
最も参考になるコメント
これがついに行われます。