mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +00:00
handle nullptr arguments with custom holder types (fixes #124)
This commit is contained in:
parent
c769fce280
commit
52f4c3aef3
@ -500,10 +500,12 @@ public:
|
||||
using type_caster<type>::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<type, holder_type> *) src.ptr();
|
||||
value = inst->value;
|
||||
holder = inst->holder;
|
||||
|
Loading…
Reference in New Issue
Block a user