mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +00:00
keep_alive: don't fail when there is no patient
This commit is contained in:
parent
7d0162a2df
commit
9b880ba743
@ -982,6 +982,9 @@ PYBIND11_NOINLINE inline void keep_alive_impl(int Nurse, int Patient, handle arg
|
||||
if (!nurse || !patient)
|
||||
pybind11_fail("Could not activate keep_alive!");
|
||||
|
||||
if (patient.ptr() == Py_None)
|
||||
return; /* Nothing to keep alive */
|
||||
|
||||
cpp_function disable_lifesupport(
|
||||
[patient](handle weakref) { patient.dec_ref(); weakref.dec_ref(); });
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user