type_caster_generic::load(): accept Py_None as input

This commit is contained in:
Wenzel Jakob 2016-02-23 13:37:14 +01:00
parent cf2b87aa5e
commit a3861b54c4

View File

@ -102,7 +102,10 @@ public:
PYBIND11_NOINLINE bool load(handle src, bool convert) { PYBIND11_NOINLINE bool load(handle src, bool convert) {
if (!src || !typeinfo) if (!src || !typeinfo)
return false; return false;
if (PyType_IsSubtype(Py_TYPE(src.ptr()), typeinfo->type)) { if (src.ptr() == Py_None) {
value = nullptr;
return true;
} else if (PyType_IsSubtype(Py_TYPE(src.ptr()), typeinfo->type)) {
value = ((instance<void> *) src.ptr())->value; value = ((instance<void> *) src.ptr())->value;
return true; return true;
} }