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

native only evals at end of render #1190

Merged
merged 1 commit into from Apr 13, 2020
Merged

native only evals at end of render #1190

merged 1 commit into from Apr 13, 2020

Conversation

@davidism
Copy link
Member

@davidism davidism commented Apr 13, 2020

If each intermediate group was converted, it could change the final value. The example given in the test is that the string 0.000 evaluates to a float, then renders as 0.0 when combined later, so 0.000{{ 7 }} would result in 0.07. Instead, intermediate groups are joined as strings, and only the final result is passed to native_concat. This also removes the need for preserve_quotes from #1086.

submitted by @mkrizek, closes #1186

@davidism davidism added this to the 2.11.2 milestone Apr 13, 2020
@davidism
Copy link
Member Author

@davidism davidism commented Apr 13, 2020

math.isclose is Python 3 only. Shakes fist at Python 2.

Co-authored-by: Martin Krizek <mkrizek@redhat.com>
@davidism davidism merged commit 179df6b into 2.11.x Apr 13, 2020
11 checks passed
@davidism davidism deleted the native-eval branch Apr 13, 2020
mkrizek added a commit to mkrizek/ansible that referenced this issue Apr 14, 2020
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.
mkrizek added a commit to ansible/ansible that referenced this issue Apr 17, 2020
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.
mkrizek added a commit to mkrizek/ansible that referenced this issue Apr 20, 2020
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 added a commit to mkrizek/ansible that referenced this issue Apr 20, 2020
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)
bcoca added a commit to bcoca/ansible that referenced this issue Apr 22, 2020
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.
bcoca added a commit to bcoca/ansible that referenced this issue Apr 28, 2020
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.
mattclay pushed a commit to ansible/ansible that referenced this issue May 6, 2020
* native types: literal_eval all the things (#68938)

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)

* Fix tests
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant