[New-bugs-announce] [issue31780] Using format spec ', x' displays incorrect error message

FHTMitchell report at bugs.python.org
Fri Oct 13 07:36:55 EDT 2017


New submission from FHTMitchell <fergus.htm at gmail.com>:

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}}')
...         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

----------
messages: 304330
nosy: FHTMitchell
priority: normal
severity: normal
status: open
title: Using format spec ',x' displays incorrect error message
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31780>
_______________________________________


More information about the New-bugs-announce mailing list