Skip to content

pathlib gets imported as a namespace #139361

@CastixGitHub

Description

@CastixGitHub

Bug report

Bug description:

I unpacked the same 3.14-rc3 tarball on two similar gentoo systems

I'm unable to reproduce the bug on both.

  • the one that works: gcc 14.3.0, configured without --with-py-debug
  • the one that doesn't work: gcc 13.3.1, --with-py-debug
>>> import _pyrepl.simple_interact
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    import _pyrepl.simple_interact
  File "/root/wip/wip/Python-3.14.0rc3/Lib/_pyrepl/simple_interact.py", line 36, in <module>
    from .readline import _get_reader, multiline_input, append_history_file
  File "/root/wip/wip/Python-3.14.0rc3/Lib/_pyrepl/readline.py", line 50, in <module>
    from .unix_console import UnixConsole as Console, _error
  File "/root/wip/wip/Python-3.14.0rc3/Lib/_pyrepl/unix_console.py", line 36, in <module>
    from . import terminfo
  File "/root/wip/wip/Python-3.14.0rc3/Lib/_pyrepl/terminfo.py", line 6, in <module>
    from pathlib import Path
ImportError: cannot import name 'Path' from 'pathlib' (unknown location)
>>> from pathlib import Path
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    from pathlib import Path
ImportError: cannot import name 'Path' from 'pathlib' (unknown location)
>>> import sys
>>> sys.modules['pathlib']
<module 'pathlib' (namespace) from ['/root/wip/wip/Python-3.14.0rc3/Lib/pathlib']>
>>>
(venv14) localhost ~/wip/wip/yeastr # ls /root/wip/wip/Python-3.14.0rc3/Lib/pathlib
__init__.py  __pycache__  _os.py  types.py

So pathlib gets imported as a PEP420 ns, yet there's a __init__

Any idea on how to debug this? Thanks!

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixesbuildThe build process and cross-buildstdlibStandard Library Python modules in the Lib/ directorytopic-pathlibtopic-replRelated to the interactive shell

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions