Commit a3861b54 by Wenzel Jakob

type_caster_generic::load(): accept Py_None as input

parent cf2b87aa
...@@ -102,7 +102,10 @@ public: ...@@ -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;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment