8000 bpo-42866: Add traverse func to _multibytecodec.MultibyteCodec by vstinner · Pull Request #24166 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-42866: Add traverse func to _multibytecodec.MultibyteCodec #24166

8000
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 2 commits into from
Jan 8, 2021
Merged

bpo-42866: Add traverse func to _multibytecodec.MultibyteCodec #24166

merged 2 commits into from
Jan 8, 2021

Conversation

vstinner
Copy link
Member
@vstinner vstinner commented Jan 8, 2021

Convert _multibytecodec.MultibyteCodec type to a GC type and adds a
traverse function.

https://bugs.python.org/issue42866

Convert _multibytecodec.MultibyteCodec type to a GC type and adds a
traverse function.
@vstinner
Copy link
Member Author
vstinner commented Jan 8, 2021

Example:

import _codecs_jp
import gc
codec = _codecs_jp.getcodec('cp932')
print(gc.get_referents(codec))

Output:

[<class '_multibytecodec.MultibyteCodec'>]

@vstinner
Copy link
Member Author
vstinner commented Jan 8, 2021

I updated the PR to track/untrack an instance in the GC.

Example:

import _codecs_jp
import gc
codec = _codecs_jp.getcodec('cp932')
# instance -> type
print(gc.get_referents(codec) == [type(codec)])
# type -> instance
print(any(ref is codec for ref in gc.get_referrers(type(codec))))

Output with the PR:

True
True

@vstinner vstinner merged commit 11ef53a into python:master Jan 8, 2021
@vstinner vstinner deleted the mbc_traverse branch January 8, 2021 14:44
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
…nGH-24166)

Convert _multibytecodec.MultibyteCodec type to a GC type and adds a
traverse function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0