You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using format spec ',x' displays incorrect error message #75961
Minor issue. Using the ',b', ',o' or ',x' raises the error
ValueError("Cannot specify ',' or '_' with 'x'.",)
(or equivalently for 'b' and 'o'). However, it is possible to use the format specs '_b', '_o' and '_x' in Python 3.6 due to PEP-515.
The following test demonstrates this:
>>> i =10000
>>> for base in'box':
... for sep in',_':
... try:
... print(f'{i:{sep}{base}}')
... exceptValueErroras err:
... print(repr(err))
ValueError("Cannot specify ',' or '_' with 'b'.",)
1_1000_0110_1010_0000ValueError("Cannot specify ',' or '_' with 'o'.",)
30_3240ValueError("Cannot specify ',' or '_' with 'x'.",)
1_86a0
The formatting part of PEP-515 was implemented in bpo-27080. Chris Angelico's initial patch https://bugs.python.org/file44152/underscores_decimal_only.patch was, as the name says, for decimal only, and added "or '_' " to the error message. The next patch added other bases but neglected to remove the obsoleted addition.
Chris, can you do a PR? I don't think any new test is needed. I would also be inclined to skip the news blurb, but since Eric should review and merge, it is his call.
I agree there's no need for tests, since we usually don't guarantee such messages going forward. Also, I think skipping the news blurb is reasonable for this change.
New changeset 28773ca by Terry Jan Reedy (Dargor) in branch 'master': bpo-31780: Fix incorrect error message for ',x', ',b', ',o' specs (bpo-4002) 28773ca
New changeset 59b5c13 by Terry Jan Reedy (Miss Islington (bot)) in branch '3.6':
[3.6] bpo-31780: Fix incorrect error message for ',x', ',b', ',o' specs (GH-4002) (bpo-4004) 59b5c13
Activity
FHTMitchell commentedon Oct 13, 2017
Minor issue. Using the ',b', ',o' or ',x' raises the error
(or equivalently for 'b' and 'o'). However, it is possible to use the format specs '_b', '_o' and '_x' in Python 3.6 due to PEP-515.
The following test demonstrates this:
terryjreedy commentedon Oct 13, 2017
The formatting part of PEP-515 was implemented in bpo-27080. Chris Angelico's initial patch https://bugs.python.org/file44152/underscores_decimal_only.patch was, as the name says, for decimal only, and added "or '_' " to the error message. The next patch added other bases but neglected to remove the obsoleted addition.
Chris, can you do a PR? I don't think any new test is needed. I would also be inclined to skip the news blurb, but since Eric should review and merge, it is his call.
ericvsmith commentedon Oct 14, 2017
I agree there's no need for tests, since we usually don't guarantee such messages going forward. Also, I think skipping the news blurb is reasonable for this change.
terryjreedy commentedon Oct 15, 2017
New changeset 28773ca by Terry Jan Reedy (Dargor) in branch 'master':
bpo-31780: Fix incorrect error message for ',x', ',b', ',o' specs (bpo-4002)
28773ca
terryjreedy commentedon Oct 15, 2017
New changeset 59b5c13 by Terry Jan Reedy (Miss Islington (bot)) in branch '3.6':
[3.6] bpo-31780: Fix incorrect error message for ',x', ',b', ',o' specs (GH-4002) (bpo-4004)
59b5c13
Rosuav commentedon Oct 18, 2017
Thanks for handling that Terry. I take it the PR isn't needed now?
I would have done it, but I'm on the way to the US (literally posting this from the airport), and hadn't gotten to looking at this in the interval.
terryjreedy commentedon Oct 18, 2017
Correct. Fixed.