Skip to content
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

2.9: native types: literal_eval all the things (#68938) #69044

Merged
merged 2 commits into from May 6, 2020

Conversation

mkrizek
Copy link
Contributor

@mkrizek mkrizek commented Apr 20, 2020

SUMMARY

With pallets/jinja#1190 merged our short-circuit
is no longer valid (has it ever been?) as now data like ' True ' may go
through our ansible_native_concat function as opposed to going through
intermediate call to Jinja2's native_concat before. Now we need to always
send data through literal_eval to ensure native types are returned.

(cherry picked from commit acdc9eb)

Backport of #68938

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

lib/ansible/template/native_helpers.py

With pallets/jinja#1190 merged our short-circuit
is no longer valid (has it ever been?) as now data like ' True ' may go
through our ansible_native_concat function as opposed to going through
intermediate call to Jinja2's native_concat before. Now we need to always
send data through literal_eval to ensure native types are returned.

(cherry picked from commit acdc9eb)
@mkrizek
Copy link
Contributor Author

mkrizek commented Apr 21, 2020

So this fails on

assert value == plugin['_meta']['hostvars'][host][key], "%s != %s" % (value, plugin['_meta']['hostvars'][host][key])
which is not in devel.

Traceback (most recent call last):
  File "./inventory_diff.py", line 66, in <module>
    main()
  File "./inventory_diff.py", line 62, in main
    check_host_vars(key, value, bdata, ahost)
  File "./inventory_diff.py", line 38, in check_host_vars
    assert value == plugin['_meta']['hostvars'][host][key], "%s != %s" % (value, plugin['_meta']['hostvars'][host][key])
AssertionError: 123456789012 != 123456789012

The values that are being compared are of different types:

value=123456789012 of type=<class 'str'>
plugin['_meta']['hostvars'][host][key]=123456789012 of type=<class 'int'>

I am looking into why is that happening.

@mattclay mattclay added the ci_verified Changes made in this PR are causing tests to fail. label Apr 21, 2020
@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 backport This PR does not target the devel branch. bug This issue/PR relates to a bug. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. labels Apr 24, 2020
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. has_issue and removed ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Apr 27, 2020
@mattclay mattclay merged commit 70b4ce5 into ansible:stable-2.9 May 6, 2020
@mkrizek mkrizek deleted the backport/2.9/68938 branch May 6, 2020 10:28
mattclay added a commit to mattclay/ansible that referenced this pull request May 7, 2020
mattclay added a commit that referenced this pull request May 8, 2020
@ansible ansible locked and limited conversation to collaborators Jun 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 backport This PR does not target the devel branch. bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. has_issue support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants