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

from importlib.resources.simple import ResourceContainer, SimpleReader
import io

class R(SimpleReader):
    @property
    def package(self): return 'x'
    def children(self): return []
    def resources(self): return []
    def open_binary(self, r): return io.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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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