pycapsule_new should return a None object if ptr is NULL.

This commit is contained in:
Siu Kwan Lam 2013-01-28 16:00:25 -06:00
commit 7aa9487f2f

View file

@ -23,6 +23,9 @@ PyObject* pycapsule_new(void* ptr,
if (!classname) {
classname = basename;
}
if (!ptr) {
Py_RETURN_NONE;
}
PyObject* cap = PyCapsule_New(ptr, basename, NULL);
if (!cap) {
PyErr_SetString(PyExc_TypeError, "Error creating new PyCapsule");