diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index a9202f6b..8547f283 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -500,10 +500,12 @@ public: using type_caster::copy_constructor; bool load(handle src, bool convert) { - if (!src || !typeinfo) + if (!src || !typeinfo) { return false; - - if (PyType_IsSubtype(Py_TYPE(src.ptr()), typeinfo->type)) { + } else if (src.ptr() == Py_None) { + value = nullptr; + return true; + } else if (PyType_IsSubtype(Py_TYPE(src.ptr()), typeinfo->type)) { auto inst = (instance *) src.ptr(); value = inst->value; holder = inst->holder;