python / python/cpython

importlib.resources.simple ResourceContainer/ResourceHandle cannot be instantiated

Open
#145,260 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib topic-importlib type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

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
  • gh-145263

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with importlib.resources.simple and inspect ResourceContainer, ResourceHandle, SimpleReader, and their Traversable relationship. Reproduce the ResourceContainer(R()) failure, then verify the abstract-property, resources access, and joinpath issues are corrected and covered by the relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.