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

master.ParentEnumerationMethod: Require matching pkg.__name__ #913

Merged
merged 6 commits into from
Mar 29, 2022

Conversation

willmerae
Copy link

Co-authored-by: Stefano Rivera [email protected]

When the requested module (e.g. ansible.module_utils.distro)

  • is provided by another module (e.g. distro)
  • that itself was a package (e.g. distro 1.7.0)

At runtime

  • ansible/module_utils/distro/__init__.py executes
  • if https://pypi.org/project/distro/ is present, it's loaded as ansible.module_utils.distro
  • otherwise ansible/module_utils/distro/_distro.py is loaded

ParentEnumerationMethod would wrongly use whatever was in sys.modules['ansible.module_utils.distro]. Instead we should ascend to the first parent that has fullname == 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

moreati and others added 6 commits March 28, 2022 14:04
Co-authored-by: Stefano Rivera <[email protected]>

When the requested module (e.g. ansible.module_utils.distro)
- is provided by another module *e.g. distro)
- that itself was a package (e.g. distro 1.7.0)

At runtime
- ansible/module_utils/distro/__init__.py executes
- if https://pypi.org/project/distro/ is present, it's loaded as
ansible.module_utils.distro
- otherwise ansible/module_utils/distro/_distro.py is loaded

ParentEnumerationMethod would wrongly use whatever was in
sys.modules['ansible.module_utils.distro]. Instead we should ascend to
the first parent that has fullname == 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 mitogen-hq#906
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mitogen broken by distro 1.7.0
2 participants