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

DM-21314: Investigate GC problems with Storable #496

Merged
merged 5 commits into from Nov 5, 2019
Merged

Conversation

kfindeisen
Copy link
Member

This PR fixes a bug that prevented Storable objects from being usable unless they were continuously referenced by Python code. The fix depends on lsst/utils#75.

It also implements and tests cloning of Python Storables, which was left unsupported due to an oversight.

std::shared_ptr<Storable> cloneStorable() const override {
/* __deepcopy__ takes an optional dict, but PYBIND11_OVERLOAD_* doesn't
* allow translation between different argument lists in C++ and Python
*/
Copy link
Member

Choose a reason for hiding this comment

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

Are you saying this will fail if __deepcopy__ is called with that argument? (Not unreasonable - using it would at least be significantly more complex, if it's even possible - just asking for clarification in the comment.)

Copy link
Member Author

@kfindeisen kfindeisen Nov 5, 2019

Choose a reason for hiding this comment

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

I'm not sure if this answers your question, but the macro will not compile if you give it arguments (like py::none() or py::dict()) that are not present in cloneStorable's argument list.

The fix involves manually keeping track of the Python "half" of an
object using a custom holder object.
The tests show that subclasses work correctly if and only if their
closest C++ base uses PySharedPtr.
@kfindeisen kfindeisen merged commit 4ef85b6 into master Nov 5, 2019
@kfindeisen kfindeisen deleted the tickets/DM-21314 branch November 5, 2019 23:17
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.

None yet

2 participants