mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-29 16:37:13 +00:00
bf8d6a2900
Now also passes the open_spiel iterated_prisoners_dilemma_test ASAN clean, in addition to all pybind11 and PyCLIF unit tests. The problem was that calling `std::shared_ptr<void>::reset()` with a `void` pointer cannot possibly update the `shared_from_this` `weak_ptr`. The solution is to store a `shd_ptr_reset` function pointer in `guarded_deleter` (similar in idea to the stored function pointer for calling `delete`). This commit still includes all debugging code, i.e. is "dirty". The code will be cleaned up after the GitHub CI is fully successful.
20 lines
426 B
Python
20 lines
426 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
import pybind11_tests.class_sh_trampoline_shared_from_this as m
|
|
|
|
|
|
class PyWithSft(m.WithSft):
|
|
pass
|
|
|
|
|
|
def test_pass_shared_ptr():
|
|
m.to_cout("")
|
|
m.to_cout(">>> obj = PyWithSft()")
|
|
obj = PyWithSft()
|
|
m.to_cout(">>> m.pass_shared_ptr(obj) #1")
|
|
m.pass_shared_ptr(obj)
|
|
m.to_cout(">>> m.pass_shared_ptr(obj) #2")
|
|
m.pass_shared_ptr(obj)
|
|
m.to_cout(">>> del obj")
|
|
del obj
|