Commit 52f4c3ae by Wenzel Jakob

handle nullptr arguments with custom holder types (fixes #124)

parent c769fce2
...@@ -500,10 +500,12 @@ public: ...@@ -500,10 +500,12 @@ public:
using type_caster<type>::copy_constructor; using type_caster<type>::copy_constructor;
bool load(handle src, bool convert) { bool load(handle src, bool convert) {
if (!src || !typeinfo) if (!src || !typeinfo) {
return false; return false;
} else if (src.ptr() == Py_None) {
if (PyType_IsSubtype(Py_TYPE(src.ptr()), typeinfo->type)) { value = nullptr;
return true;
} else if (PyType_IsSubtype(Py_TYPE(src.ptr()), typeinfo->type)) {
auto inst = (instance<type, holder_type> *) src.ptr(); auto inst = (instance<type, holder_type> *) src.ptr();
value = inst->value; value = inst->value;
holder = inst->holder; holder = inst->holder;
......
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