From a3861b54c4a739db21fc3f7a3bbc9b58d787e045 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Tue, 23 Feb 2016 13:37:14 +0100 Subject: [PATCH] type_caster_generic::load(): accept Py_None as input --- include/pybind11/cast.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index b153d6ef..bd504bf8 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; }