Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Different output from importlib.resources.files() in REPL in 3.12 versus 3.13 #121190

Open
Labels
stdlibPython modules in the Lib dirtopic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error
@danielhollas

Description

@danielhollas

Bug report

Bug description:

Runningimportlib.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 toLib/_pyrepl. Even more surprising though is that this also happens when running the OLD REPL withTERM=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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtopic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp