[New-bugs-announce] [issue44200] Recommend importlib.abc.Traversable users to implement __fspath__

Filipe Laíns report at bugs.python.org
Thu May 20 20:09:17 EDT 2021

New submission from Filipe Laíns <lains at riseup.net>:

The files()/Traversable api is meant to replace ResourceReader api, but it falls short in one dimension, tying the abstraction to a file system path.

I propose to document that Traversable users *should* implement __fspath__ if the Traversable represents a file-system path.

This will essentially make os.fspath(importlib.resources.files(module) / resource) the equivalent of importlib.resources.path(module, resource), for which currently there is no replacement using files().

messages: 394083
nosy: FFY00, brett.cannon, jaraco
priority: normal
severity: normal
status: open
title: Recommend importlib.abc.Traversable users to implement __fspath__
versions: Python 3.10

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list