Skip to content

Call tp_clear of base unmanaged type #1541

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
Sep 14, 2021

Conversation

lostmsu
Copy link
Member

@lostmsu lostmsu commented Sep 5, 2021

What does this implement/fix? Explain your changes.

Calls tp_clear (if any) of base unmanaged type when a reflected CLR object instance is cleared.

Does this close any currently open issues?

#1476

Any other comments?

C# exceptions inherit from Python BaseException class, which has tp_clear. Prior to this change it was not called when Python deallocated them leaving dangling references to BaseException.args and BaseException.__cause__.

Checklist

Check all those that are applicable and complete.

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

…ject instance is cleared

fixes pythonnet#1476 : C# exceptions inherit from Python BaseException class, which has tp_clear. Prior to this change it was not called, leaving dangling references to BaseException.args and BaseException.__cause__.call tp_clear of base unmanaged type when a reflected CLR object instance is cleared

fixes pythonnet#1476 : C# exceptions inherit from Python BaseException class, which has tp_clear. Prior to this change it was not called, leaving dangling references to BaseException.args and BaseException.__cause__.
@lostmsu
Copy link
Member Author

lostmsu commented Sep 5, 2021

@amos402 can you review this one?

The 3.7 MacOS CI failure is preexisting: https://github.com/pythonnet/pythonnet/runs/3267749344

@lostmsu lostmsu merged commit 2ef6b50 into pythonnet:master Sep 14, 2021
@lostmsu lostmsu deleted the bugs/MemLeak-CatchingExceptions branch September 14, 2021 19:18
@lostmsu lostmsu restored the bugs/MemLeak-CatchingExceptions branch September 14, 2021 19:28
@lostmsu lostmsu deleted the bugs/MemLeak-CatchingExceptions branch September 14, 2021 19:29
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.

1 participant