[issue47142] Document importlib.resources.abc.Traversable

Jason R. Coombs report at bugs.python.org
Sun Apr 3 09:04:38 EDT 2022


Jason R. Coombs <jaraco at jaraco.com> added the comment:

> Are the methods expected to raise specific exception types (e.g. if a resource is missing, or you call iterdir on a “file”)?

The short answer is no. The protocol does not stipulate specific exceptions. Perhaps it should be documented that any exceptions that occur when accessing the backing resource will propagate. Although, I do believe that statement is true for all Python code unless stated otherwise.

I agree it would be nice if the protocol could stipulate which exceptions might be raised by a given implementation, but I'm not confident that's possible, at least not without wrapping/adapting the pathlib.Path and zipfile.Path objects.

Does that answer the question? Are you working on another provider that implements this protocol? I'd be happy to consult on that effort.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue47142>
_______________________________________


More information about the Python-bugs-list mailing list