This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Decimal and float formatting treat '%' differently for infinities and nans.
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, mark.dickinson, python-dev, r.david.murray, skrah
Priority: normal Keywords: patch

Created on 2014-07-27 10:08 by mark.dickinson, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue22090.diff skrah, 2014-08-18 22:45 review
Messages (17)
msg224114 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2014-07-27 10:08
There's a minor inconsistency between Decimal and float formatting for the `%` format type when handling infinities and nans:

>>> from decimal import Decimal
>>> format(float('inf'), '.2%')  # includes trailing '%'
'inf%'
>>> format(Decimal('inf'), '.2%')  # no trailing '%'
'Infinity'

I think the Decimal result should have a '%' on it.
msg224115 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2014-07-27 10:11
I agree that Decimal is wrong here. PEP 3101 says the result should include the trailing '%'.
msg225510 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2014-08-18 22:45
I guess it's the right thing to do and here's a patch. Could one of you double check the decimal.py part?
msg225519 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2014-08-19 07:39
The decimal.py part LGTM.  (The rest looks good, too, but I haven't tested it.)  This seems like one of those bugs that probably isn't worth backporting to 3.4, but given the projected longevity of 2.7 it might be worth applying there.
msg225763 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2014-08-23 21:08
Thanks.  I agree about 2.7 -- including 3.4 would perhaps make
external libmpdec management easier for Debian and Arch.

I'm not suggesting that we should always consider the distributors,
but this particular issue seems so minor.
msg225926 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-08-26 18:50
New changeset 5c585929658a by Stefan Krah in branch '3.4':
Issue #22090: Fix '%' formatting for infinities and NaNs.
http://hg.python.org/cpython/rev/5c585929658a

New changeset 37ebb0d44808 by Stefan Krah in branch '2.7':
Issue 22090: Fix '%' formatting for infinities and NaNs.
http://hg.python.org/cpython/rev/37ebb0d44808
msg225927 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-08-26 19:55
Looks like there is a bug of some sort, eg:

http://buildbot.python.org/all/builders/AMD64%20Fedora%20without%20threads%203.4/builds/466
msg225928 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2014-08-26 20:12
I think only the builders --with-system-libmpdec fail.  That's inevitable, since they still use libmpdec-2.4.0.

Starting from 7fbb912c0789 they should fail building _decimal entirely until I upgrade the system libmpdec on the builders.
msg225932 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2014-08-26 22:00
It seems _decimal is imported even if _decimal.so is not built.
I've opened #22280 for that.

Regarding this patch, everything looks fine to me.
msg225935 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-08-26 22:32
As long as you have a plan to get the buildbots fixed in a timely fashion.
msg225936 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-08-26 22:33
(To be clear, I'm talking about the stable buildbots :)
msg225939 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2014-08-27 00:41
I'm not sure that I understand. IMHO this issue does not break any buildbots.
The current situation is that it exposes an unrelated import issue (#22280).

I can camouflage that issue by upgrading the FreeBSD and the Fedora bot to
libmpdec-2.4.1 (once it's out), but I'd rather see the import issue fixed
first.
msg225947 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-08-27 06:01
Well, we have a goal of keeping the stable buildbots green.  If something turns one or more red, it should either be fixed promptly, or the changeset that turned it red backed out until a fix is ready.

The reason for keeping them green is so we know right away when a changeset is bad.  If some are red, we don't get alerted to new breakage.
msg225976 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2014-08-27 11:58
The revisions that cause the bot to go red (6c468df214dc and 227ce85bdbe0) are
quite recent, so I suggest we address the failure in #22285.
msg225987 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-08-27 14:00
I'm not going to argue this any further, but "recent" is exactly the point...if all of the bots had turned red you'd understand that it needed to be fixed *immediately* or the triggering change (regardless of what the actual bug was) backed out.  Since it isn't all the bots it isn't that critical, but eventually we want to make it critical (ie: someday it will be a requirement that *all* stable bots pass before a change gets *committed*...but that day is still a longer way off than I'd like, since I at least don't have much time for working on the workflow stuff).
msg225993 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2014-08-27 15:27
> I'm not going to argue this any further, but "recent" is exactly the point...if all of the bots had turned red you'd understand that it needed to be fixed *immediately* or the triggering change (regardless of what the actual bug was) backed out.  Since it isn't all the bots it isn't that critical, but eventually we want to make it critical (ie: someday it will be a requirement that *all* stable bots pass before a change gets *committed*...but that day is still a longer way off than I'd like, since I at least don't have much time for working on the workflow stuff).

How is this supposed to work though?  In this case 6c468df214dc and 227ce85bdbe0
need to be backed out, since they apparently also broke the OpenIndiana bot long
ago (why wasn't that discovered?).

However, I don't feel that it is my place to back them out, since I did not
commit them and might step on other people's toes.

I don't think that the burden of having green buildbots should be on the
person who commits something that *exposes* existing issues (unless, as
you say, *all* buildbots turn red).
msg225997 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-08-27 15:55
Yeah, right now that's fine.  We'll work out the more strict process if/when we start actually enforcing it :)
History
Date User Action Args
2022-04-11 14:58:06adminsetgithub: 66288
2021-10-23 21:13:11yaubisetnosy: - yaubi
2014-08-27 15:56:00r.david.murraysetmessages: + msg225997
2014-08-27 15:27:40skrahsetmessages: + msg225993
2014-08-27 14:00:54r.david.murraysetmessages: + msg225987
2014-08-27 11:58:02skrahsetmessages: + msg225976
2014-08-27 06:01:46r.david.murraysetmessages: + msg225947
2014-08-27 00:41:18skrahsetmessages: + msg225939
2014-08-26 22:33:24r.david.murraysetmessages: + msg225936
2014-08-26 22:32:48r.david.murraysetmessages: + msg225935
2014-08-26 22:00:13skrahsetstatus: open -> closed

messages: + msg225932
2014-08-26 20:12:15skrahsetmessages: + msg225928
2014-08-26 19:55:40r.david.murraysetstatus: closed -> open
nosy: + r.david.murray
messages: + msg225927

2014-08-26 19:02:22skrahsetstatus: open -> closed
stage: resolved
resolution: fixed
components: + Library (Lib)
versions: + Python 2.7, Python 3.4
2014-08-26 18:50:52python-devsetnosy: + python-dev
messages: + msg225926
2014-08-23 21:08:31skrahsetmessages: + msg225763
2014-08-19 07:39:49mark.dickinsonsetmessages: + msg225519
2014-08-18 22:45:43skrahsetfiles: + issue22090.diff
keywords: + patch
messages: + msg225510
2014-07-29 03:40:04yaubisetnosy: + yaubi
2014-07-27 10:11:02eric.smithsetmessages: + msg224115
2014-07-27 10:08:43mark.dickinsoncreate