Bug report
Bug description:
Running importlib.resources.files() without specifying the anchor parameter in interactive REPL in Python 3.12 raises a rather unhelpful error:
>>> import importlib.resources >>> importlib.resources.files() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib64/python3.12/importlib/resources/_common.py", line 45, in wrapper return func() ^^^^^^ File "/usr/lib64/python3.12/importlib/resources/_common.py", line 56, in files return from_package(resolve(anchor)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.12/importlib/resources/_common.py", line 113, in from_package reader = spec.loader.get_resource_reader(spec.name) ^^^^^^^^^ File "/usr/lib64/python3.12/importlib/resources/_adapters.py", line 17, in __getattr__ return getattr(self.spec, name) ^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'name'
It would be nice to return something more helpful. The documentation doesn't mention that this function can raise, so I am assuming that raising AttributeError is not part of the public API?
However, on a locally built Python from current main branch, this call returns a path to Lib/_pyrepl. Even more surprising though is that this also happens when running the OLD REPL with TERM=dumb ./python
❯ TERM=dumb ./python Python 3.14.0a0 (heads/main:1a84bdc237, Jun 30 2024, 21:44:46) [GCC 13.3.1 20240522 (Red Hat 13.3.1-1)] on linux Type "help", "copyright", "credits" or "license" for more information. warning: can't use pyrepl: terminal doesn't have the required clear capability >>> import importlib.resources >>> importlib.resources.files() PosixPath('/home/hollas/software/cpython/Lib/_pyrepl')
CPython versions tested on:
3.12, CPython main branch
Operating systems tested on:
Linux