keep_alive: don't fail when there is no patient

This commit is contained in:
Wenzel Jakob 2016-04-25 03:25:13 +02:00
parent 7d0162a2df
commit 9b880ba743

View File

@ -982,6 +982,9 @@ PYBIND11_NOINLINE inline void keep_alive_impl(int Nurse, int Patient, handle arg
if (!nurse || !patient) if (!nurse || !patient)
pybind11_fail("Could not activate keep_alive!"); pybind11_fail("Could not activate keep_alive!");
if (patient.ptr() == Py_None)
return; /* Nothing to keep alive */
cpp_function disable_lifesupport( cpp_function disable_lifesupport(
[patient](handle weakref) { patient.dec_ref(); weakref.dec_ref(); }); [patient](handle weakref) { patient.dec_ref(); weakref.dec_ref(); });