[issue45427] importlib.readers.MultiplexedPath

David Rajaratnam report at bugs.python.org
Mon Oct 11 06:03:23 EDT 2021


David Rajaratnam <daver at gemarex.com.au> added the comment:

Thanks for the quick response. I think the attached file shows the issue. 

In the directory where you download and run this file create a sub-directory 'data'. Then running the file creates the output (note: I've truncated the path name):

> Traverse data: MultiplexedPath('<<abspath-deleted>>/data') (<class 'importlib.readers.MultiplexedPath'>)

I think the idea behind MultiplexedPath() is that it merges together multiple base/root directories so even though in this case it is a single path it wouldn't necessarily be the case in general. So while it makes sense that for some MultiplexedPath object X that str(X) isn't itself a proper directory path, however, there seems to be no method/property to access these root paths.

Note: Traverable.iterdir() iterates over the files/sub-directories in the root(s) so doesn't return the root path(s) themselves.

A further note. If you add a file `data/__init__.py` then data is now a package and running the code this time returns a PosixPath object (on a posix system): 

> Traverse data: <<abspath-deleted>>/data (<class 'pathlib.PosixPath'>)
> X: <<abspath-deleted>>/data/__init__.py (<class 'pathlib.PosixPath'>)
> X: <<abspath-deleted>>/data/__pycache__ (<class 'pathlib.PosixPath'>)

----------
Added file: https://bugs.python.org/file50342/navigate.py

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


More information about the Python-bugs-list mailing list