STINNER Victor added the comment:

Both patches look good to me. Do you feel motivated to check if all formating 
methods have a test? Here is a list of format methods:

PyUnicode_Format():
- 3.3, 3.4: formatchar() raises OverflowError if x > MAX_UNICODE
- 2.7: formatchar() raises OverflowError if x > 0x10ffff (or x > 0xffff, in 
narrow mode)

PyUnicode_FromFromatV():
- 2.7: no check, *s++ = va_arg(vargs, int); => BUG
- 3.3: indirect check, maxchar = Py_MAX(maxchar, ordinal); and then 
PyUnicode_New(n, maxchar); should fail => (ok)
- 3.4: raise ValueError if ordinal > MAX_UNICODE => OK

int.__format__('c'):
- 3.3, 3.4: format_long_internal() raises OverflowError if x > 0x10ffff => OK
- 2.7: format_int_or_long_internal() raises OverflowError if x > 0x10ffff (or x 
> 0xffff in narrow mode) => OK

IMO a ValueError would be better than OverflowError, it's not really an 
overflow (limitation of the C language, or a C type). It is maybe too late to 
change this.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18184>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to