-
Notifications
You must be signed in to change notification settings - Fork 801
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
Make the format strings compatible with Python 2.6 #361
Conversation
Can you add the DCO? |
Signed-off-by: Victor Grigoriu <vgrigoriu@gmail.com>
164bf06
to
9e818db
Compare
Done. |
The tests are failing on 2.6, are you sure this is broken? |
Looking into the failing tests. |
So, I think I figured things out. The tests fail in Python 2.6 because of this line. The test tests that all those values generate In Python 2.6, without my changes, the test passes because this line, coincidentally, throws With my changes, this line no longer throws The difference in the result of Obviously I don't know why this specific value was chosen for this test, but maybe we should remove it? What do you think @brian-brazil? |
Signed-off-by: Victor Grigoriu <vgrigoriu@gmail.com>
Odd that CI let this though.
It's there specifically to catch this. This sounds like https://bugs.python.org/issue7117 or https://bugs.python.org/issue7632 |
Signed-off-by: Victor Grigoriu <vgrigoriu@gmail.com>
prometheus_client/utils.py
Outdated
@@ -18,6 +18,6 @@ def floatToGoString(d): | |||
# Go switches to exponents sooner than Python. | |||
# We only need to care about positive values for le/quantile. | |||
if d > 0 and dot > 6: | |||
mantissa = '{0}.{1}{2}'.format(s[0], s[1:dot], s[dot+1:]).rstrip('0.') | |||
mantissa = '{0}.{1}{2}'.format(s[0], s[1:dot], s[dot+1:16]).rstrip('0.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is correct, as it's the underlying algorithm that's not right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you saying that there's no easy way to preserve compatibility with Python 2.6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly not, we'd need our own floating point renderer for it.
May I ask why you're still on 2.6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my sins :-P
I'll close the PR then, I'm good with using 0.4.2 until we can upgrade to Python 2.7.
We should still fix the format bug on 2.6 |
So what do you want to do about the test failing on 2.6? |
Can skip the test on 2.6 only with a message referencing the floating point formatting compatibility issue. |
Signed-off-by: Victor Grigoriu <vgrigoriu@gmail.com>
Thanks! |
This should restore compatibility with Python 2.6, current version fails with: