[issue47161] pathlib method relative_to doesnt work with // in paths
Eryk Sun
report at bugs.python.org
Fri Apr 1 10:26:55 EDT 2022
Eryk Sun <eryksun at gmail.com> added the comment:
> Hmm..., I get it, but Im not gonna lie it's pretty confusing given
> that in other places `//` works as a substitute for `/`. Maybe it
> should be mentioned in the documentation?
In Linux, the system resolves "//" as just "/". In other POSIX systems, such as Cygwin or MSYS2 (running in Windows), "//" is a UNC path of the form "//server/share/filepath". I would expect resolve() to handle this. For example:
Linux:
>>> p = pathlib.Path('//tmp')
>>> p
PosixPath('//tmp')
>>> p.resolve()
PosixPath('/tmp')
However, resolve() is broken for a UNC path in 3.9 under MSYS2:
>>> p = pathlib.Path('//localhost/C$/temp')
>>> p.exists()
True
>>> p.resolve()
PosixPath('/localhost/C$/temp')
>>> p.resolve().exists()
False
realpath() is also broken for this case in 3.9 under MSYS2:
>>> os.path.realpath(p)
'/localhost/C$/temp'
----------
nosy: +eryksun
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue47161>
_______________________________________
More information about the Python-bugs-list
mailing list