[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'.",)
ValueError("Cannot specify ',' or '_' with 'o'.",)
ValueError("Cannot specify ',' or '_' with 'x'.",)

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>

More information about the New-bugs-announce mailing list