Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5f2c508

Browse files
ZackerySpytzserhiy-storchaka
authored andcommitted
bpo-36150: Fix possible assertion failures due to _ctypes.c's PyCData_reduce(). (GH-12106)
1 parent 48600c7 commit 5f2c508

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

Modules/_ctypes/_ctypes.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2743,10 +2743,11 @@ PyCData_reduce(PyObject *myself, PyObject *args)
27432743
"ctypes objects containing pointers cannot be pickled");
27442744
return NULL;
27452745
}
2746-
return Py_BuildValue("O(O(NN))",
2747-
_unpickle,
2748-
Py_TYPE(myself),
2749-
PyObject_GetAttrString(myself, "__dict__"),
2746+
PyObject *dict = PyObject_GetAttrString(myself, "__dict__");
2747+
if (dict == NULL) {
2748+
return NULL;
2749+
}
2750+
return Py_BuildValue("O(O(NN))", _unpickle, Py_TYPE(myself), dict,
27502751
PyBytes_FromStringAndSize(self->b_ptr, self->b_size));
27512752
}
27522753

0 commit comments

Comments
 (0)