Closed as not planned
Closed as not planned
Description
Bug report
Global packages (e.g. enum
) try to import from local packages in the current working dir, even if a same-named stdlib package exists.
For instance, if a types.py
exists in the local directory, import enum
will fail:
> touch types.py
> python
Python 3.10.9 (main, Jan 20 2023, 17:02:49) [Clang 13.0.0 (clang-1300.0.27.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import enum
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/kai/.pyenv/versions/3.10.9/lib/python3.10/enum.py", line 2, in <module>
from types import MappingProxyType, DynamicClassAttribute
ImportError: cannot import name 'MappingProxyType' from 'types' (/home/kai/sandbox/types.py)
The correct package to import should be the stdlib types.py
package, not the local types.py
.
Your environment
- CPython versions tested on: Python 3.10.4, 3.10.9, 3.8.6
- Bug does not come up in 3.8.7
- Operating system and architecture: Mac x86_64