summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOren Milman <orenmn@gmail.com>2017-09-24 09:21:42 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-09-24 09:21:42 (GMT)
commit4facdf523aa6967487a9425f124da9661b59fd43 (patch)
tree9a6c9501fda968eefcac5965e1a96c469a908397
parent2b382dd6121bb1e4b75470fb3ef8555665df3eb6 (diff)
downloadcpython-4facdf523aa6967487a9425f124da9661b59fd43.zip
cpython-4facdf523aa6967487a9425f124da9661b59fd43.tar.gz
cpython-4facdf523aa6967487a9425f124da9661b59fd43.tar.bz2
bpo-31311: Impove error reporting in case the first argument to PyCData_setstate() isn't a dictionary. (#3255)
-rw-r--r--Modules/_ctypes/_ctypes.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 1942c63..8afb8cc 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -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);