Non-package module loaded from ModInfo object retains __path__ from previously loaded package.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
Bug report
Assume you have two separate modules with the same name. One is a package, one is not.
Use pkgutil.itermodules to get a ModuleInfo object for the package, then load the it using find_module and load_module. This object has a __path__ object with the location of package, as expected.
Next, do the same for the non-package module. The resulting module object should have no __path__ attribute, but instead it has one with the location of the package opened previously.
This can be replicated with a structure such as \module\submodule\submodule.py, using \module and \module\submodule as the arguments for the two calls to pkgutil.itermodules.
Your environment
- CPython versions tested on: 3.10.7, 3.11.0rc2
- Operating system and architecture: Windows 10
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior with the two module layouts described in the issue, using pkgutil.itermodules followed by find_module and load_module. Compare the package and non-package module objects; done means the non-package module no longer retains a path from the previously loaded package.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100