[issue42531] importlib.resources.path() raises TypeError for packages without __file__

Jason R. Coombs report at bugs.python.org
Wed Dec 2 17:25:09 EST 2020


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

Thanks William for the detailed problem description.

If the issue has been fixed on Python 3.9 but not on 3.8, then it was likely a redesign that enabled the improved behavior, a redesign that won't be ported back to Python 3.8 and earlier. In these situations, the best recommendation is often to just rely on importlib_resources (the backport) for those older Python versions.

In this case, you've identified a fairly surgical fix that may be suitable to apply to these older affected Pythons, so I'll consider that, but before I do, have you considered using importlib_resources for Python 3.8 and earlier? That would likely also address the issue and you could adopt it sooner.

To some extent, the behavior you've described could be considered a bug or could be considered a feature request (add support for path on packages that have no __spec__.origin). I am not aware whether this limitation was by design or incidental.

----------

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


More information about the Python-bugs-list mailing list