Skip to content

gh-145260: fix(importlib.resources.simple): Make ResourceContainer and ResourceH…#145263

Open
zetzschest wants to merge 4 commits intopython:mainfrom
zetzschest:fix/importlib_simple_resource_traversable
Open

gh-145260: fix(importlib.resources.simple): Make ResourceContainer and ResourceH…#145263
zetzschest wants to merge 4 commits intopython:mainfrom
zetzschest:fix/importlib_simple_resource_traversable

Conversation

@zetzschest
Copy link

@zetzschest zetzschest commented Feb 26, 2026

Problem

ResourceContainer and ResourceHandle cannot be instantiated because Traversable now requires name as an abstract property. Also, iterdir() accesses self.reader.resources without calling it, and ResourceHandle.joinpath has a signature mismatch.

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

Fix

  • Add name property to ResourceContainer and ResourceHandle
  • Add iterdir to ResourceHandle
  • Fix self.reader.resourcesself.reader.resources() in ResourceContainer.iterdir()
  • Fix ResourceHandle.joinpath to accept *descendants

… ResourceHandle

ResourceContainer and ResourceHandle could not be instantiated because
Traversable now requires name as an abstract property. Additionally,
ResourceContainer.iterdir() accessed self.reader.resources without
calling it, and ResourceHandle.joinpath had a signature mismatch.

- Add name property to ResourceContainer
- Fix self.reader.resources -> self.reader.resources() call
- Add iterdir() method to ResourceHandle
- Fix ResourceHandle.joinpath to accept *descendants
@bedevere-app
Copy link

bedevere-app bot commented Feb 26, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@zetzschest zetzschest marked this pull request as ready for review February 26, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant