Sitelet https://web.archive.org/web/20201229115859/https://github.com/fluentpython/example-code/issues/24
Skip to content
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

_abc_registry attribute is not available in python 3.7.0 #24

Open
1vec opened this issue Aug 31, 2018 · 2 comments
Open

_abc_registry attribute is not available in python 3.7.0 #24

1vec opened this issue Aug 31, 2018 · 2 comments

Comments

@1vec
Copy link

@1vec 1vec commented Aug 31, 2018

When I try running the tombola_runner.py in chapter 11, python reports to me that the '_abc_registry' doesn't exist.

I searched in docs, but found that the attribute is not accesible anymore.

The changelog is
"""
bpo-31333: _abc module is added. It is a speedup module with C implementations for various functions and methods in abc. Creating an ABC subclass and calling isinstance or issubclass with an ABC subclass are up to 1.5x faster. In addition, this makes Python start-up up to 10% faster.

Note that the new implementation hides internal registry and caches, previously accessible via private attributes _abc_registry, _abc_cache, and _abc_negative_cache. There are three debugging helper methods that can be used instead _dump_registry, _abc_registry_clear, and _abc_caches_clear.
"""

@ShubhamBelwal
Copy link

@ShubhamBelwal ShubhamBelwal commented Oct 30, 2018 •

You can use abc._get_dump(Tombola) - it returns a 4-tuple of (_abc_registry, _abc_cache, _abc_negative_cache, _abc_negative_cache_version)

The following code should work:

import abc
virtual_subclasses = [ref() for ref in abc._get_dump(Tombola)[0] if ref()]

Credit goes to: u/K9000_ from the reddit thread

@anancds
Copy link
Contributor

@anancds anancds commented Jun 30, 2020

@ShubhamBelwal thanks, it fixed my same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.