You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The weakref trick used by with_custodian_and_ward relies on the nurse object being cleared before it calls the callback which drops the reference to the patient. This is mostly but not always true: when the cyclic garbage collector runs, it first makes all weakref callbacks before freeing the garbage (at least in Python 2.7.12). This can lead to the patient's destructor running before the nurse's, with dire consequences if the nurse references the patient in its destructor.
pybind11 uses the same weakref trick and suffers the same bug: pybind/pybind11#856.
The weakref trick used by
with_custodian_and_ward
relies on the nurse object being cleared before it calls the callback which drops the reference to the patient. This is mostly but not always true: when the cyclic garbage collector runs, it first makes all weakref callbacks before freeing the garbage (at least in Python 2.7.12). This can lead to the patient's destructor running before the nurse's, with dire consequences if the nurse references the patient in its destructor.pybind11 uses the same weakref trick and suffers the same bug: pybind/pybind11#856.
Example code
keepalive.cpp:
test.py:
Output:
The text was updated successfully, but these errors were encountered: