Show attribute names in leak tracker #2291
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Needed for 3.11 classes with lazy dictionaries
Issue
Needed for python 3.11 update ( see #2267 ), but works fine with 3.10
Description
In python 3.11 classes only create the dictionary object if needed ( faster-cpython/ideas#72 ).
When finding owners for objects in the leak tracker, and having an object held by a class like:
previously we
gc.get_referrers(ob1)
would give us thedict
(i.e.container.__dict__
) and from that we would find the key. Nowgc.get_referrers(ob1)
gives us the instance, and it is not clear which attribute it is.The change add a case for a class, and adds the attribute name to
extra_info
. The act of looking at the__dict__
causes it to be created, so that we can get the name.Also fix the test class name.
Testing
This fixes the leaktracker test when running with python 3.11 and above
Acceptance Criteria
Tests should pass
Documentation
release notes