Skip to content

bpo-29638: Fix spurious refleaks after typing is imported #469

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

Conversation

ilevkivskyi
Copy link
Member

Fixes http://bugs.python.org/issue29638

This adds three more caches to refleak.py/clear_caches().

@mention-bot
Copy link

@ilevkivskyi, thanks for your PR! By analyzing the history of the files in this pull request, we identified @Haypo and @serhiy-storchaka to be potential reviewers.

# These classes require special treatment because they do not appear
# in direct subclasses of collections.abc classes
abs_classes = list(abs_classes) + [t.ChainMap, t.Counter, t.DefaultDict]
for abc in abs_classes:
for obj in abc.__subclasses__() + [abc]:
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to proceed subclasses of typing.ChainMap etc?

Copy link
Member Author

Choose a reason for hiding this comment

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

They do not have subclasses yet, but if in future they will have some, then yes we will need to process them.
(Now however we need to process subclasses of other classes in abs_classes list)

Copy link
Member Author

Choose a reason for hiding this comment

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

On a second thought I think it is better to have this, because e.g. Counter[int] is a subclass of Counter, and Counter[int] is created in test_typing.

@serhiy-storchaka serhiy-storchaka added needs backport to 3.5 tests Tests in the Lib/test dir labels Mar 5, 2017
@serhiy-storchaka serhiy-storchaka merged commit 7acffa2 into python:master Mar 5, 2017
@ilevkivskyi
Copy link
Member Author

Thanks for merging this!
Actually, I am not sure this needs a backport, since the typing.ChainMap etc. were added after 3.6.0

@serhiy-storchaka
Copy link
Member

I see them in 3.5.

@ilevkivskyi
Copy link
Member Author

Ah, sorry, you are right, they were backported to 3.5 :-) Then this code could be backported unmodified, I will make PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants