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:
>>>importimportlib.resources>>>importlib.resources.files()
Traceback (mostrecentcalllast):
File"<stdin>", line1, in<module>File"/usr/lib64/python3.12/importlib/resources/_common.py", line45, inwrapperreturnfunc()
^^^^^^File"/usr/lib64/python3.12/importlib/resources/_common.py", line56, infilesreturnfrom_package(resolve(anchor))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"/usr/lib64/python3.12/importlib/resources/_common.py", line113, infrom_packagereader=spec.loader.get_resource_reader(spec.name)
^^^^^^^^^File"/usr/lib64/python3.12/importlib/resources/_adapters.py", line17, in__getattr__returngetattr(self.spec, name)
^^^^^^^^^^^^^^^^^^^^^^^^AttributeError: 'NoneType'objecthasnoattribute'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 ./pythonPython3.14.0a0 (heads/main:1a84bdc237, Jun302024, 21:44:46) [GCC13.3.120240522 (RedHat13.3.1-1)] onlinuxType"help", "copyright", "credits"or"license"formoreinformation.
warning: can't use pyrepl: terminal doesn'thavetherequiredclearcapability>>>importimportlib.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
Linked PRs
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: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 withTERM=dumb ./pythonCPython versions tested on:
3.12, CPython main branch
Operating systems tested on:
Linux
Linked PRs
importlib.resources.files()when module spec is None #138531importlib.resources.files()when module spec isNone" #148460