Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[smart_holder] Enable properties for non-owning holders #4586

Merged
merged 4 commits into from
Mar 24, 2023

Conversation

rwgk
Copy link
Collaborator

@rwgk rwgk commented Mar 23, 2023

Description

The new test is a reduced use case found in the wild.

This supports the PyCLIF-pybind11 integration.

Suggested changelog entry:

Ralf W. Grosse-Kunstleve added 4 commits March 22, 2023 18:06
Failing:

```
__________________________________________________________ test_persistent_holder __________________________________________________________

    def test_persistent_holder():
        h = m.DataFieldsHolder(2)
>       c = h.vec_at(0).core_fld
E       RuntimeError: Non-owning holder (loaded_as_shared_ptr).

h          = <pybind11_tests.class_sh_property_non_owning.DataFieldsHolder object at 0x7fabab516470>

test_class_sh_property_non_owning.py:6: RuntimeError
__________________________________________________________ test_temporary_holder ___________________________________________________________

    def test_temporary_holder():
        d = m.DataFieldsHolder(2).vec_at(1)
>       c = d.core_fld
E       RuntimeError: Non-owning holder (loaded_as_shared_ptr).

d          = <pybind11_tests.class_sh_property_non_owning.DataField object at 0x7fabab548770>

test_class_sh_property_non_owning.py:13: RuntimeError
```
… `property_cpp_function`s with `const shared_ptr<T> &` arguments.

Tests are incomplete.
Copy link
Contributor

@wangxf123456 wangxf123456 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good to me.

@rwgk rwgk marked this pull request as ready for review March 24, 2023 00:21
@rwgk rwgk merged commit 37d0bf4 into pybind:smart_holder Mar 24, 2023
@rwgk rwgk deleted the property_non_owning_sh branch March 24, 2023 00:21
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Mar 24, 2023
@rwgk rwgk removed the needs changelog Possibly needs a changelog entry label Mar 24, 2023
rwgk pushed a commit to rwgk/pybind11 that referenced this pull request Mar 24, 2023
rwgk pushed a commit that referenced this pull request Mar 24, 2023
* use C++17 syntax to get rid of recursive template instantiations for concatenating type signatures (#4587)

* Apply descr.h `src_loc` change (smart_holder PR #4022) to code added with master PR #4587

* Add test_class_sh_property_non_owning to CMakeLists.txt (fixes oversight in PR #4586)

* Resolve clang-tidy errors.

* clang-tidy auto fix

---------

Co-authored-by: Konstantin Bespalov <kos5tya@yandex.ru>
rwgk pushed a commit to rwgk/pybind11clif that referenced this pull request Mar 24, 2023
…ranch).

The behavior change made it possible to exercise the `reference_internal` vs `copy` behavior more thoroughly, which then led to a surprise discovery. See SURPRISE comment in tests/test_class_sh_property_stl.py
rwgk pushed a commit to rwgk/pybind11clif that referenced this pull request Mar 24, 2023
…ranch).

The behavior change made it possible to exercise the `reference_internal` vs `copy` behavior more thoroughly, which then led to a surprise discovery. See SURPRISE comment in tests/test_class_sh_property_stl.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants