Skip to content

Conversation

pablogsal
Copy link
Member

@pablogsal pablogsal commented Oct 15, 2017

As can be checked in the discussion for bpo-31780 there is an incorrect error message when using the ',b', ',o' or ',x' formatters:

>>> i = 10000
>>> for base in 'box':
        for sep in ',_':
            try:
                print(f'{i:{sep}{base}}')
            except ValueError as err:
                print(repr(err))

ValueError("Cannot specify ',' or '_' with 'b'.",)
1_1000_0110_1010_0000
ValueError("Cannot specify ',' or '_' with 'o'.",)
30_3240
ValueError("Cannot specify ',' or '_' with 'x'.",)
1_86a0

This PR fixes this so now we obtain:

>>> i = 10000
>>> for base in 'box':
        for sep in ',_':
            try:
                print(f'{i:{sep}{base}}')
            except ValueError as err:
                print(repr(err))

ValueError("Cannot specify ',' with 'b'.",)
1_1000_0110_1010_0000
ValueError("Cannot specify ',' with 'o'.",)
30_3240
ValueError("Cannot specify ',' with 'x'.",)
1_86a0

https://bugs.python.org/issue31780

@miss-islington
Copy link
Contributor

Thanks @pablogsal for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 15, 2017
@bedevere-bot
Copy link

GH-4004 is a backport of this pull request to the 3.6 branch.

@terryjreedy
Copy link
Member

If there were a more complete name in your bugs.python.org profile, I would have used it.

terryjreedy pushed a commit that referenced this pull request Oct 15, 2017
@pablogsal pablogsal deleted the bpo31780 branch October 15, 2017 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants