Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the formatting part of PEP 515, '_' in numeric literals. #71267

Closed
ericvsmith opened this issue May 21, 2016 · 13 comments
Closed

Implement the formatting part of PEP 515, '_' in numeric literals. #71267

ericvsmith opened this issue May 21, 2016 · 13 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) release-blocker type-feature A feature request or enhancement

Comments

@ericvsmith
Copy link
Member

BPO 27080
Nosy @brettcannon, @birkenfeld, @ericvsmith, @ned-deily, @Rosuav
Files
  • underscores_decimal_only.patch
  • underscores_all_bases.patch
  • underscores_with_tests.patch
  • moar-tests.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/ericvsmith'
    closed_at = <Date 2016-09-10.03:08:14.367>
    created_at = <Date 2016-05-21.20:38:09.840>
    labels = ['interpreter-core', 'type-feature', 'release-blocker']
    title = "Implement the formatting part of PEP 515, '_' in numeric literals."
    updated_at = <Date 2016-09-10.03:08:14.366>
    user = 'https://github.com/ericvsmith'

    bugs.python.org fields:

    activity = <Date 2016-09-10.03:08:14.366>
    actor = 'eric.smith'
    assignee = 'eric.smith'
    closed = True
    closed_date = <Date 2016-09-10.03:08:14.367>
    closer = 'eric.smith'
    components = ['Interpreter Core']
    creation = <Date 2016-05-21.20:38:09.840>
    creator = 'eric.smith'
    dependencies = []
    files = ['44152', '44153', '44154', '44425']
    hgrepos = []
    issue_num = 27080
    keywords = ['patch']
    message_count = 13.0
    messages = ['266023', '273093', '273117', '273120', '273123', '274769', '275150', '275151', '275165', '275367', '275545', '275549', '275550']
    nosy_count = 6.0
    nosy_names = ['brett.cannon', 'georg.brandl', 'eric.smith', 'ned.deily', 'python-dev', 'Rosuav']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue27080'
    versions = ['Python 3.6']

    @ericvsmith
    Copy link
    Member Author

    I've separated this out from bpo-26331, so as to not interfere with discussions and code reviews for the parsing portion of the PEP.

    @ericvsmith ericvsmith self-assigned this May 21, 2016
    @ericvsmith ericvsmith added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels May 21, 2016
    @ericvsmith
    Copy link
    Member Author

    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.

    @ericvsmith ericvsmith removed their assignment Aug 19, 2016
    @Rosuav
    Copy link
    Contributor

    Rosuav commented Aug 19, 2016

    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.

    @Rosuav
    Copy link
    Contributor

    Rosuav commented Aug 19, 2016

    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!

    @Rosuav
    Copy link
    Contributor

    Rosuav commented Aug 19, 2016

    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.

    @Rosuav
    Copy link
    Contributor

    Rosuav commented Sep 7, 2016

    Another couple of tests, per comments.

    @brettcannon
    Copy link
    Member

    Latest patch LGTM. If Georg isn't able to get to issue bpo-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?

    @brettcannon
    Copy link
    Member

    Actually, Chris doesn't have commit privileges so I just will. :)

    @Rosuav
    Copy link
    Contributor

    Rosuav commented Sep 8, 2016

    Thanks Brett! Sounds like a plan.

    @ericvsmith
    Copy link
    Member Author

    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.

    @ericvsmith ericvsmith self-assigned this Sep 9, 2016
    @ericvsmith
    Copy link
    Member Author

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Sep 10, 2016

    New changeset 99abb731ea7a by Eric V. Smith in branch 'default':
    bpo-27080: PEP-515: add '_' formatting option.
    https://hg.python.org/cpython/rev/99abb731ea7a

    @ericvsmith
    Copy link
    Member Author

    I also fixed the code so both '_' and ',' can't be specified, and added tests. The documentation is also updated.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs) release-blocker type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants