[issue7267] format method: c presentation type broken

STINNER Victor report at bugs.python.org
Tue Jul 2 02:34:30 CEST 2013


STINNER Victor added the comment:

u'{0:c}'.format(256) calls 256.__format__('c') which returns a str (bytes) object, so we must reject value outside range(0, 256). The real fix for this issue is to upgrade to Python 3.

Attached patch works around the inital issue (u'{0:c}'.format(256)) by raising OverflowError on int.__format__('c') if the value is not in range(0, 256).

----------
Added file: http://bugs.python.org/file30747/int_format_c.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7267>
_______________________________________


More information about the Python-bugs-list mailing list