mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 13:15:12 +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;
|
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user