[issue5515] 'n' formatting for int and float handles leading zero padding poorly
Eric Smith e...@trueblade.com added the comment: Fixed in trunk as part of r71796. Closing the issue. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5515 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5515] 'n' formatting for int and float handles leading zero padding poorly
Eric Smith e...@trueblade.com added the comment: Fixed in trunk (will be 3.1) in r71665. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5515 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5515] 'n' formatting for int and float handles leading zero padding poorly
Changes by Eric Smith e...@trueblade.com: -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5515 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5515] 'n' formatting for int and float handles leading zero padding poorly
Eric Smith e...@trueblade.com added the comment: Fixed in py3k (will be 3.1) in r71665. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5515 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5515] 'n' formatting for int and float handles leading zero padding poorly
Eric Smith e...@trueblade.com added the comment: This won't get fixed in 3.0 or 2.6. Still not sure about 2.7, but I'm considering how to fix it there. -- versions: -Python 2.6, Python 3.0 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5515 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5515] 'n' formatting for int and float handles leading zero padding poorly
Eric Smith e...@trueblade.com added the comment: C# doesn't seem to have the issue because they don't allow any modifies when specifying locale-aware formatting. Specifying a picture seems to be the only way to get leading zeros added. Similarly, Java looks to be picture-based. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5515 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5515] 'n' formatting for int and float handles leading zero padding poorly
Eric Smith e...@trueblade.com added the comment: Oops, assigning it to you was an error. I was just trying to figure out what your userid is so I could add you to Nosy, and I was using Assigned To to find it. I've fixed that. The current behavior is an accident of the implementation. The implementation isn't based on anything else, and there was no requirement to have the output that it does. And as far as I know, there are no tests that test for the current behavior. Right now I'm +0 on backporting. What I'll do is fix it for 2.7/3.1 and see how big the patch is. I suspect it will be a pretty big, invasive patch. If so, I'll change my backport vote to -1. -- assignee: marketdickinson - eric.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5515 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5515] 'n' formatting for int and float handles leading zero padding poorly
New submission from Eric Smith e...@trueblade.com: I think the way leading zero padding is handled for int and float by format's 'n' code is a bug. import locale locale.setlocale(locale.LC_ALL, 'en_US.UTF8') 'en_US.UTF8' format(12345, '010n') '12,345' format(12345, '09n') '00012,345' format(12345, '08n') '0012,345' format(12345, '07n') '012,345' format(12345, '06n') '12,345' When 'n' support was added to Decimal, leading zeros had commas in them: from decimal import Decimal format(Decimal(12345), '010n') '00,012,345' format(Decimal(12345), '09n') '0,012,345' format(Decimal(12345), '08n') '0,012,345' format(Decimal(12345), '07n') '012,345' format(Decimal(12345), '06n') '12,345' Decimal also has the same support for PEP 378's ',' modifier: format(Decimal(12345), '010,') '00,012,345' format(Decimal(12345), '09,') '0,012,345' format(Decimal(12345), '08,') '0,012,345' format(Decimal(12345), '07,') '012,345' format(Decimal(12345), '06,') '12,345' As I'm implementing PEP 378 for int and float, I'm going to make it work the same way that Decimal works. For consistency, and because I think the current behavior is not useful, I'd like to change float and int formatting with 'n' to match Decimal and PEP 378 for the ',' modifier. Since I consider this a bug, I'd like to consider backporting it to 2.6 and 3.0, if the changes aren't too intrusive. -- assignee: marketdickinson components: Interpreter Core messages: 83797 nosy: eric.smith, marketdickinson, rhettinger severity: normal status: open title: 'n' formatting for int and float handles leading zero padding poorly type: behavior versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5515 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5515] 'n' formatting for int and float handles leading zero padding poorly
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: I concur with your plan. BTW, have you checked to see what Java and C# do? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5515 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com