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

Fix for #45620: "Salt CLI is rounding floats to 2 decimal places" #49187

Merged
merged 2 commits into from Aug 20, 2018

Conversation

Projects
None yet
4 participants
@erwindon
Copy link
Contributor

commented Aug 18, 2018

What does this PR do?

This PR fixes a number representation issue under older Python versions.

What issues does this PR fix or reference?

#45620

Previous Behavior

Numbers were represented with a maximum of 12 digits of precision.

New Behavior

Numbers are represented with the maximum precision.
For the DOUBLE format that is used, that is about 16 digits.

In python issue https://bugs.python.org/issue9337 it was decided that the artificial limitation to 12 digits should be removed. Therefore starting with Python3.2 it behaves differently (better).

Tests written?

No
Test with salt-call test.echo 1234567890.123456
When using python27 the result previously was 1234567890.12
When using python34 the result previously was 1234567890.123456
Now the result is 1234567890.123456 in all cases.

@cachedout
Copy link
Collaborator

left a comment

Very nice!

@erwindon

This comment has been minimized.

Copy link
Contributor Author

commented Aug 18, 2018

@cachedout build fails for py3-centos-7. it seems unrelated to my change. previous build was ok and only a small comment changed. the job complains about a salt-master being unreachable in 2 cases. what is the proper way forward?

erwindon added some commits Aug 18, 2018

Fix for #45620: "Salt CLI is rounding floats to 2 decimal places" (ac…
…tually: Salt CLI is using only 12 digits for precision)

use repr() to get the full precision also for older python versions
as until about python32 it was limited to 12 digits only by default

@erwindon erwindon force-pushed the erwindon:py27fixnumberformat branch from 6876bbb to 12261a5 Aug 19, 2018

@gtmanfred gtmanfred merged commit 5ba7f60 into saltstack:2017.7 Aug 20, 2018

7 of 8 checks passed

jenkins/pr/py3-centos-7 The py3-centos-7 job has failed
Details
WIP ready for review
Details
continuous-integration/jenkins/pr-merge This commit looks good
Details
jenkins/pr/docs The docs job has passed
Details
jenkins/pr/lint The lint job has passed
Details
jenkins/pr/py2-centos-7 The py2-centos-7 job has passed
Details
jenkins/pr/py2-ubuntu-1604 The py2-ubuntu-1604 job has passed
Details
jenkins/pr/py3-ubuntu-1604 The py3-ubuntu-1604 job has passed
Details

@erwindon erwindon deleted the erwindon:py27fixnumberformat branch Aug 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.