mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-05 22:23:21 +00:00
[smart_holder] Add gil_scoped_acquire to shared_ptr_trampoline_self_life_support ctor. (#4196)
* Add `gil_scoped_acquire` to `shared_ptr_trampoline_self_life_support` ctor.
* Add test exercising fix & validation that the fix is needed (i.e. this is BROKEN).
test_class_sh_trampoline_shared_ptr_cpp_arg.py::test_std_make_shared_factory[pass_through_shd_ptr] PASSED [ 87%]
test_class_sh_trampoline_shared_ptr_cpp_arg.py::test_std_make_shared_factory[pass_through_shd_ptr_release_gil] FAILED [100%]
```
================================================================= FAILURES =================================================================
______________________________________ test_std_make_shared_factory[pass_through_shd_ptr_release_gil] ______________________________________
pass_through_func = <built-in method pass_through_shd_ptr_release_gil of PyCapsule object at 0x7f1b209707b0>
@pytest.mark.parametrize(
"pass_through_func", [m.pass_through_shd_ptr, m.pass_through_shd_ptr_release_gil]
)
def test_std_make_shared_factory(pass_through_func):
class PyChild(m.SpBase):
def __init__(self):
super().__init__(0)
obj = PyChild()
while True:
> assert pass_through_func(obj) is obj
E RuntimeError: NEEDED HERE: gil_scoped_acquire gil;
```
* Put back fix.
This commit is contained in:
committed by
GitHub
parent
4e1e2fe62a
commit
59ef5307ae
@@ -132,12 +132,15 @@ def test_infinite():
|
||||
break # Comment out for manual leak checking (use `top` command).
|
||||
|
||||
|
||||
def test_std_make_shared_factory():
|
||||
@pytest.mark.parametrize(
|
||||
"pass_through_func", [m.pass_through_shd_ptr, m.pass_through_shd_ptr_release_gil]
|
||||
)
|
||||
def test_std_make_shared_factory(pass_through_func):
|
||||
class PyChild(m.SpBase):
|
||||
def __init__(self):
|
||||
super().__init__(0)
|
||||
|
||||
obj = PyChild()
|
||||
while True:
|
||||
assert m.pass_through_shd_ptr(obj) is obj
|
||||
assert pass_through_func(obj) is obj
|
||||
break # Comment out for manual leak checking (use `top` command).
|
||||
|
||||
Reference in New Issue
Block a user