mirror of https://github.com/python/cpython
Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise
OverflowError when an argument of %c format is out of range.
This commit is contained in:
commit
c89533f72f
|
@ -2048,6 +2048,8 @@ class UnicodeTest(string_tests.CommonTest,
|
||||||
b'%c', c_int(0xabcd))
|
b'%c', c_int(0xabcd))
|
||||||
check_format('\U0010ffff',
|
check_format('\U0010ffff',
|
||||||
b'%c', c_int(0x10ffff))
|
b'%c', c_int(0x10ffff))
|
||||||
|
with self.assertRaises(OverflowError):
|
||||||
|
PyUnicode_FromFormat(b'%c', c_int(0x110000))
|
||||||
# Issue #18183
|
# Issue #18183
|
||||||
check_format('\U00010000\U00100000',
|
check_format('\U00010000\U00100000',
|
||||||
b'%c%c', c_int(0x10000), c_int(0x100000))
|
b'%c%c', c_int(0x10000), c_int(0x100000))
|
||||||
|
|
|
@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise
|
||||||
|
OverflowError when an argument of %c format is out of range.
|
||||||
|
|
||||||
- Issue #18137: Detect integer overflow on precision in float.__format__()
|
- Issue #18137: Detect integer overflow on precision in float.__format__()
|
||||||
and complex.__format__().
|
and complex.__format__().
|
||||||
|
|
||||||
|
|
|
@ -2496,7 +2496,7 @@ unicode_fromformat_arg(_PyUnicodeWriter *writer,
|
||||||
{
|
{
|
||||||
int ordinal = va_arg(*vargs, int);
|
int ordinal = va_arg(*vargs, int);
|
||||||
if (ordinal < 0 || ordinal > MAX_UNICODE) {
|
if (ordinal < 0 || ordinal > MAX_UNICODE) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"character argument not in range(0x110000)");
|
"character argument not in range(0x110000)");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue