Issue 6902: Built-in types format incorrectly with 0 padding. (original) (raw)
Issue6902
Created on 2009-09-13 23:36 by eric.smith, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (5) | ||
---|---|---|
msg92586 - (view) | Author: Eric V. Smith (eric.smith) * ![]() |
Date: 2009-09-13 23:36 |
Originally discussed in issue 6871. Even if an alignment of "<" is specified, "=" is used if the padding character is "0". >>> format(2, '0<20') '00000000000000000002' >>> format(2, '1<20') '21111111111111111111' This is a problem for at least float and integers. This should probably be backported to 2.6 and 3.1, but I'll have to wait and see how invasive the patch is. | ||
msg92607 - (view) | Author: Eric V. Smith (eric.smith) * ![]() |
Date: 2009-09-14 11:59 |
complex will also need to be addressed. The second error message is misleading, for the same reason the formatting on float and int is incorrect: >> format(3-2j, "0<30") Traceback (most recent call last): File "", line 1, in ValueError: Zero padding is not allowed in complex format specifier >>> format(3-2j, "0=30") Traceback (most recent call last): File "", line 1, in ValueError: Zero padding is not allowed in complex format specifier But this is correct: >>> format(3-2j, "=30") Traceback (most recent call last): File "", line 1, in ValueError: '=' alignment flag is not allowed in complex format specifier It's not 0 padding that's not allowed, it's the implied sign alignment when using 0 (without a specified alignment). | ||
msg93742 - (view) | Author: Alyssa Coghlan (ncoghlan) * ![]() |
Date: 2009-10-08 12:31 |
Note that the 2.6 branch didn't seem to suffer this problem when I checked it earlier tonight. | ||
msg99849 - (view) | Author: Eric V. Smith (eric.smith) * ![]() |
Date: 2010-02-22 22:05 |
The root of this problem is an interaction with ',' formatting that was introduced in 2.7 and 3.1. I'm still trying to figure out how to implement it. I'm changing the priority to low because I can't imagine this is a problem in practice. If anyone thinks otherwise, please comment and give a use case. | ||
msg99889 - (view) | Author: Eric V. Smith (eric.smith) * ![]() |
Date: 2010-02-23 00:40 |
Fixed: trunk: r78349 py3k: r78350 release31-maint: r78352 |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:56:52 | admin | set | github: 51151 |
2010-02-23 00:40:21 | eric.smith | set | status: open -> closedresolution: acceptedmessages: + stage: resolved |
2010-02-22 22:05:48 | eric.smith | set | priority: normal -> lowmessages: + |
2010-02-22 15:15:41 | eric.smith | set | versions: - Python 2.6 |
2009-12-14 05:16:05 | ezio.melotti | set | nosy: + ezio.melottitype: behavior |
2009-12-14 04:05:24 | falsetru | set | nosy: + falsetru |
2009-10-08 12:31:08 | ncoghlan | set | nosy: + ncoghlanmessages: + |
2009-10-08 12:26:32 | ncoghlan | link | issue7081 superseder |
2009-09-14 11:59:08 | eric.smith | set | messages: + |
2009-09-13 23:36:43 | eric.smith | create |