[New-bugs-announce] [issue32442] Result of pathlib.Path.resolve() with UNC path is not very useful
report at bugs.python.org
Thu Dec 28 14:09:57 EST 2017
New submission from Tzu-ping Chung <uranusjr at gmail.com>:
The behaviour of os.path.abspath() and pathlib.Path.resolve() is a different when dealing with a path on a UNC share (on Windows):
>>> import os, pathlib
>>> path = pathlib.Path('Z:\foo')
This is not necessarily a problem by itself, just a consequence of calling different APIs underneath (although it probably worths a mention in documentation). The real problem is that the UNC path is not really useful anywhere in the Python standard library (AFAIK), and there’s no way to turn the it (back) into network drive once you call resolve(). The only way to get a network drive path is to
Some possibile solutions:
1. Change the behaviour of resolve() to return the network drive path instead. This would be the most straightforward, API-wise, but is backward-incompatible, and maybe the original implementation did this on purpose?
2. Add a as_absolute() to pathlib.Path. On Windows this would mirror the result of os.path.abspath(); on POSIX this would probably be identical to resolve().
3. Add an argument to resolve()? This is essentially the same as 2., just interfaced differently.
components: Library (Lib), Windows
nosy: paul.moore, steve.dower, tim.golden, uranusjr, zach.ware
title: Result of pathlib.Path.resolve() with UNC path is not very useful
versions: Python 3.6
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce