Skip to content

Clear weakref list when reflected object is destroyed #1758

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

Merged
merged 1 commit into from
Apr 9, 2022

Conversation

lostmsu
Copy link
Member

@lostmsu lostmsu commented Apr 8, 2022

What does this implement/fix? Explain your changes.

According to official documentation for defining extension types, if they are to support weak references, they must clear weak reference list associated with the instance in tp_clear.

This was missed when #1267 was superseded.

P.S. without the fix corresponding test would crash with segfault due to an attempt to dereference an object that no longer exists via a weak reference to it.

Does this close any currently open issues?

N/A

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change

@lostmsu lostmsu added this to the 3.0.0 milestone Apr 8, 2022
@lostmsu
Copy link
Member Author

lostmsu commented Apr 9, 2022

Also @amos402 if you have time. This reintroduces bits of your old PR from Oct 2020.

@lostmsu lostmsu requested a review from filmor April 9, 2022 00:01
@filmor filmor merged commit 50da522 into pythonnet:master Apr 9, 2022
@lostmsu lostmsu deleted the weakref-support branch April 9, 2022 15:47
lostmsu added a commit to losttech/pythonnet that referenced this pull request Apr 9, 2022
According to official documentation for defining extension types, if they are to support weak references, they must clear weak reference list associated with the instance in tp_clear.

Extension types were missed in pythonnet#1758 ( 50da522 )
lostmsu added a commit to losttech/pythonnet that referenced this pull request Apr 9, 2022
According to official documentation for defining extension types, if they are to support weak references, they must clear weak reference list associated with the instance in tp_clear.

Extension types were missed in pythonnet#1758 ( 50da522 )
filmor pushed a commit that referenced this pull request Apr 10, 2022
According to official documentation for defining extension types, if they are to support weak references, they must clear weak reference list associated with the instance in tp_clear.

Extension types were missed in #1758 ( 50da522 )
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