diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index b153d6ef2..bd504bf86 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -102,7 +102,10 @@ public: PYBIND11_NOINLINE bool load(handle src, bool convert) { if (!src || !typeinfo) 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 *) src.ptr())->value; return true; }