bpo-31311: Impove error reporting in case the first argument to PyCData_setstate() isn't a dictionary. (#3255)

This commit is contained in:
Oren Milman 2017-09-24 12:21:42 +03:00 committed by Serhiy Storchaka
parent 2b382dd612
commit 4facdf523a
1 changed files with 4 additions and 1 deletions

View File

@ -2665,8 +2665,11 @@ PyCData_setstate(PyObject *myself, PyObject *args)
int res;
PyObject *dict, *mydict;
CDataObject *self = (CDataObject *)myself;
if (!PyArg_ParseTuple(args, "Os#", &dict, &data, &len))
if (!PyArg_ParseTuple(args, "O!s#",
&PyDict_Type, &dict, &data, &len))
{
return NULL;
}
if (len > self->b_size)
len = self->b_size;
memmove(self->b_ptr, data, len);