# Out of scope variable in jinja2 template started throwing error after i updated to jinja2 2.9

**URL:** <https://forum.ansible.com/t/out-of-scope-variable-in-jinja2-template-started-throwing-error-after-i-updated-to-jinja2-2-9/25656>\
**Category:** Ansible Project\
**Created:** [October 2, 2017, 1:28pm UTC](https://forum.ansible.com/t/out-of-scope-variable-in-jinja2-template-started-throwing-error-after-i-updated-to-jinja2-2-9/25656 "2017-10-02T13:28:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ishan\_jain](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@ishan\_jain](https://forum.ansible.com/u/ishan_jain)\
**Post date:** [October 2, 2017, 1:28pm UTC](https://forum.ansible.com/t/out-of-scope-variable-in-jinja2-template-started-throwing-error-after-i-updated-to-jinja2-2-9/25656/1 "2017-10-02T13:28:10Z")

</div>

My previously running playbooks starting giving me error after i updated my python modules. After a lot of debugging, i identified the problem. The problem was that following code snippet was working fine until i updated jinja2 to 2.9

`

{% for dictValue in someDictVar -%}  
#something something  
{% endfor -%}

#This var is used outside its scope. was working earlier but not anymore.  
{% if dictValue.someVar is defined -%}  
…

`

So my question is, why was out of scope thing working earlier and why did it start to break in 2.9 ?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 2, 2017, 5:57pm UTC](https://forum.ansible.com/t/out-of-scope-variable-in-jinja2-template-started-throwing-error-after-i-updated-to-jinja2-2-9/25656/2 "2017-10-02T17:57:39Z")

</div>

You'll probably get a better chance for an answer by asking the Jinja2 project
