mirror of
https://github.com/pybind/pybind11.git
synced 2025-01-19 17:32:37 +00:00
f45bb585c3
For example keep_alive<0,1>() should work where the return value may sometimes be None. At present a "Could not allocate weak reference!" exception is thrown. Update documentation to clarify behaviour of keep_alive when nurse is None or does not support weak references.
68 lines
885 B
Python
68 lines
885 B
Python
from __future__ import print_function
|
|
import sys
|
|
import gc
|
|
sys.path.append('.')
|
|
|
|
from example import Parent, Child
|
|
|
|
if True:
|
|
p = Parent()
|
|
p.addChild(Child())
|
|
gc.collect()
|
|
print(p)
|
|
p = None
|
|
|
|
gc.collect()
|
|
print("")
|
|
|
|
if True:
|
|
p = Parent()
|
|
p.returnChild()
|
|
gc.collect()
|
|
print(p)
|
|
p = None
|
|
|
|
gc.collect()
|
|
print("")
|
|
|
|
if True:
|
|
p = Parent()
|
|
p.addChildKeepAlive(Child())
|
|
gc.collect()
|
|
print(p)
|
|
p = None
|
|
|
|
gc.collect()
|
|
print("")
|
|
|
|
if True:
|
|
p = Parent()
|
|
p.returnChildKeepAlive()
|
|
gc.collect()
|
|
print(p)
|
|
p = None
|
|
|
|
gc.collect()
|
|
print("")
|
|
|
|
if True:
|
|
p = Parent()
|
|
p.returnNullChildKeepAliveChild()
|
|
gc.collect()
|
|
print(p)
|
|
p = None
|
|
|
|
gc.collect()
|
|
print("")
|
|
|
|
if True:
|
|
p = Parent()
|
|
p.returnNullChildKeepAliveParent()
|
|
gc.collect()
|
|
print(p)
|
|
p = None
|
|
|
|
gc.collect()
|
|
print("")
|
|
print("Terminating..")
|