master.ParentEnumerationMethod: Require matching pkg.__name__ #913
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.
Co-authored-by: Stefano Rivera [email protected]
When the requested module (e.g.
ansible.module_utils.distro
)distro
)At runtime
ansible/module_utils/distro/__init__.py
executesansible.module_utils.distro
ansible/module_utils/distro/_distro.py
is loadedParentEnumerationMethod would wrongly use whatever was in
sys.modules['ansible.module_utils.distro]
. Instead we should ascend to the first parent that hasfullname == sys.modules[fullname].__name__
. Then descend to the appropriate .py file on disk.This bug didn't show up before because until distro 1.7.0 (Feb 2022) the top-level distro module was a module (
distro.py
) not a package (distro/__init__.py
)fixes #906