summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Modules/_ctypes/_ctypes.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 48ad696e10..be0b321bad 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -2663,10 +2663,11 @@ PyCData_reduce(PyObject *myself, PyObject *args)
"ctypes objects containing pointers cannot be pickled");
return NULL;
}
- return Py_BuildValue("O(O(NN))",
- _unpickle,
- Py_TYPE(myself),
- PyObject_GetAttrString(myself, "__dict__"),
+ PyObject *dict = PyObject_GetAttrString(myself, "__dict__");
+ if (dict == NULL) {
+ return NULL;
+ }
+ return Py_BuildValue("O(O(NN))", _unpickle, Py_TYPE(myself), dict,
PyBytes_FromStringAndSize(self->b_ptr, self->b_size));
}