Issue #16147: PyUnicode_FromFormatV() now raises an error if the argument of
'%c' is not in the range(0x110000).
This commit is contained in:
parent
3921e90c5a
commit
ff5a848db5
|
@ -2417,6 +2417,11 @@ unicode_fromformat_arg(_PyUnicodeWriter *writer,
|
||||||
case 'c':
|
case 'c':
|
||||||
{
|
{
|
||||||
int ordinal = va_arg(*vargs, int);
|
int ordinal = va_arg(*vargs, int);
|
||||||
|
if (ordinal < 0 || ordinal > MAX_UNICODE) {
|
||||||
|
PyErr_SetString(PyExc_ValueError,
|
||||||
|
"character argument not in range(0x110000)");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
if (_PyUnicodeWriter_Prepare(writer, 1, ordinal) == -1)
|
if (_PyUnicodeWriter_Prepare(writer, 1, ordinal) == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
PyUnicode_WRITE(writer->kind, writer->data, writer->pos, ordinal);
|
PyUnicode_WRITE(writer->kind, writer->data, writer->pos, ordinal);
|
||||||
|
|
Loading…
Reference in New Issue