Issue 27080: Implement the formatting part of PEP 515, '_' in numeric literals. (original) (raw)

Created on 2016-05-21 20:38 by eric.smith, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
underscores_decimal_only.patch Rosuav,2016-08-19 13:24 review
underscores_all_bases.patch Rosuav,2016-08-19 13:34 review
underscores_with_tests.patch Rosuav,2016-08-19 13:52 review
moar-tests.patch Rosuav,2016-09-07 06:33 review
Messages (13)
msg266023 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2016-05-21 20:38
I've separated this out from issue 26331, so as to not interfere with discussions and code reviews for the parsing portion of the PEP.
msg273093 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2016-08-19 08:23
Unfortunately I'm not going to have time to implement this before 3.6 beta 1, so I'm un-assigning it to myself. I'll post to python-dev and hopefully someone else can get to it. Apologies for waiting so long.
msg273117 - (view) Author: Chris Angelico (Rosuav) * Date: 2016-08-19 13:24
Here's a first-cut patch. No docs, no tests, and applies only to decimal formatting. It involves redefining the thousands_separators flag from being a boolean to being a three-state flag (none, comma, or underscore), and (ab)uses LT_*_LOCALE to carry that same information around.
msg273120 - (view) Author: Chris Angelico (Rosuav) * Date: 2016-08-19 13:34
Hmm, adding bin/oct/hex support didn't turn out that hard. Although it feels like this code is getting hackish. Definitely needs code review!
msg273123 - (view) Author: Chris Angelico (Rosuav) * Date: 2016-08-19 13:52
Hmm, strange. Comma formatting never seems to have had tests added. So I've added a couple of simple tests of comma formatting at the same time as adding underscore formatting tests. Also, test_long.py currently has a comment "# octal" preceding a bunch of tests of *binary* formatting, and no tests of octal. So I've added those too. In any case, here's a patch with full functionality and tests.
msg274769 - (view) Author: Chris Angelico (Rosuav) * Date: 2016-09-07 06:33
Another couple of tests, per comments.
msg275150 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2016-09-08 20:48
Latest patch LGTM. If Georg isn't able to get to issue #26331 then I'll commit to tomorrow. Do you want me to commit yours on your behalf right after, Chris to make sure this hits b1?
msg275151 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2016-09-08 20:48
Actually, Chris doesn't have commit privileges so I just will. :)
msg275165 - (view) Author: Chris Angelico (Rosuav) * Date: 2016-09-08 21:28
Thanks Brett! Sounds like a plan.
msg275367 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2016-09-09 18:11
Since Brett is working on the parsing part, I'll work on this. I might take a stab at the documentation first, but in any event I'll commit it tonight.
msg275545 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2016-09-10 02:28
I just noticed that the patch doesn't handle 'X' (uppercase) correctly, while it does handle 'x' (lowercase). I'll fix that when I commit.
msg275549 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-10 03:07
New changeset 99abb731ea7a by Eric V. Smith in branch 'default': Issue 27080: PEP 515: add '_' formatting option. https://hg.python.org/cpython/rev/99abb731ea7a
msg275550 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2016-09-10 03:08
I also fixed the code so both '_' and ',' can't be specified, and added tests. The documentation is also updated.
History
Date User Action Args
2022-04-11 14:58:31 admin set github: 71267
2016-09-10 03:08:14 eric.smith set status: open -> closedresolution: fixedmessages: + stage: resolved
2016-09-10 03:07:00 python-dev set nosy: + python-devmessages: +
2016-09-10 02:28:00 eric.smith set messages: +
2016-09-09 18:11:39 eric.smith set assignee: eric.smithmessages: +
2016-09-08 21:28:39 brett.cannon set priority: normal -> release blockernosy: + ned.deily
2016-09-08 21:28:07 Rosuav set messages: +
2016-09-08 20:48:39 brett.cannon set messages: +
2016-09-08 20:48:16 brett.cannon set nosy: + brett.cannonmessages: +
2016-09-07 06:33:49 Rosuav set files: + moar-tests.patchmessages: +
2016-08-19 13:52:32 Rosuav set files: + underscores_with_tests.patchmessages: +
2016-08-19 13:34:11 Rosuav set files: + underscores_all_bases.patchmessages: +
2016-08-19 13:24:12 Rosuav set files: + underscores_decimal_only.patchkeywords: + patchmessages: +
2016-08-19 13:17:06 Rosuav set nosy: + Rosuav
2016-08-19 08:23:18 eric.smith set assignee: eric.smith -> (no value)messages: + versions: + Python 3.6
2016-05-21 20:39:00 eric.smith set nosy: + georg.brandl
2016-05-21 20:38:09 eric.smith create