Make the format strings compatible with Python 2.6#361
Make the format strings compatible with Python 2.6#361brian-brazil merged 4 commits intoprometheus:masterfrom
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
| # 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.
I'm not sure this is correct, as it's the underlying algorithm that's not right.
There was a problem hiding this comment.
Are you saying that there's no easy way to preserve compatibility with Python 2.6?
There was a problem hiding this comment.
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.
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: