-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
referencing variable out of scope #31786
Comments
@lavie Greetings! Thanks for taking the time to open this issue. In order for the community to handle your issue effectively, we need a bit more information. Here are the items we could not find in your description:
Please set the description of this issue with this template: |
ISSUE TYPE
COMPONENT NAMEmodule_utils/basic.py ANSIBLE VERSIONmaster CONFIGURATIONOS / ENVIRONMENTOSX SUMMARYreferencing undefined variable STEPS TO REPRODUCEansible/lib/ansible/module_utils/basic.py Line 2542 in f2ade09
In the following code:
If the first |
(I updated the initial bug comment with info from #31786 (comment)) |
ansible/lib/ansible/module_utils/basic.py
Line 2542 in f2ade09
In the following code:
If the first
open
raises an exception, then theif out_dest
fails with either a "trying to reference undefined variable" or a "dereferencing variable before assignment" error, depending on the python version I guess. I ran into this corner case in a situation that's a bit hard to recreate while using lineinfile and unsafe writes. However, you can test a simplified version of this code in interactive python to see that the issue does exist (works for me with python 2.7).SUMMARY
referencing undefined variable
ISSUE TYPE
COMPONENT NAME
module_utils/basic.py
ANSIBLE VERSION
master
OS / ENVIRONMENT
OSX
STEPS TO REPRODUCE
The text was updated successfully, but these errors were encountered: