Skip to content

importlib.resources.simple ResourceContainer/ResourceHandle cannot be instantiated #145260

Description

@zetzschest

Bug report

Bug description:

Issue

ResourceContainer and ResourceHandle cannot be instantiated because Traversable now declares name as an abstract property. Additionally, ResourceContainer.iterdir() accesses self.reader.resources without calling it, and ResourceHandle.joinpath has a signature mismatch with the base class.

Reproducer

fromimportlib.resources.simpleimportResourceContainer, SimpleReaderimportioclassR(SimpleReader):
@propertydefpackage(self): return'x'defchildren(self): return []
defresources(self): return []
defopen_binary(self, r): returnio.BytesIO(b'')
ResourceContainer(R()) # TypeError: Can't instantiate abstract class ResourceContainer

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-importlibtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions