mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Issue #11302: missing type check on _string.formatter_field_name_split and _string.formatter_parser caused crash.
Originial patch by haypo, reviewed by me, okayed by Georg.
This commit is contained in:
parent
08d4293013
commit
a1eac7218b
2 changed files with 62 additions and 0 deletions
|
|
@ -1192,6 +1192,11 @@ formatter_parser(PyObject *ignored, STRINGLIB_OBJECT *self)
|
|||
{
|
||||
formatteriterobject *it;
|
||||
|
||||
if (!PyUnicode_Check(self)) {
|
||||
PyErr_Format(PyExc_TypeError, "expected str, got %s", Py_TYPE(self)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
it = PyObject_New(formatteriterobject, &PyFormatterIter_Type);
|
||||
if (it == NULL)
|
||||
return NULL;
|
||||
|
|
@ -1332,6 +1337,11 @@ formatter_field_name_split(PyObject *ignored, STRINGLIB_OBJECT *self)
|
|||
PyObject *first_obj = NULL;
|
||||
PyObject *result = NULL;
|
||||
|
||||
if (!PyUnicode_Check(self)) {
|
||||
PyErr_Format(PyExc_TypeError, "expected str, got %s", Py_TYPE(self)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
it = PyObject_New(fieldnameiterobject, &PyFieldNameIter_Type);
|
||||
if (it == NULL)
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue