This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mliska
Recipients mliska
Date 2017-12-27.20:13:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1514405616.88.0.213398074469.issue32434@psf.upfronthosting.co.za>
In-reply-to
Content
The documentation for pathlib.Path.resolve says: "Make the path absolute, resolving any symlinks."

On Windows, the behavior doesn't always match the first part of the statement.

Example:
On a system with an existing, but empty directory C:\Test.
Running the interpreter at C:\ resolve behaves like so:

>>> os.path.realpath(r'Test\file')
'C:\\Test\\file'
>>> WindowsPath(r'Test\file').resolve(strict=False)
WindowsPath('C:/Test/file')

When running the interpreter inside C:\Test it instead behaves in the following manner:

>>> os.path.realpath('file')
'C:\\Test\\file'
>>> WindowsPath('file').resolve(strict=False)
WindowsPath('file')

Resolving a path object specifying a non-existent relative path results in an identical (relative) path object.
This is also inconsistent with the behavior of os.path.realpath as demonstrated.

The root of the issue is in the pathlib._WindowsFlavour.resolve method at lines 193, 199 and 201.
If at least one component of the path gets resolved at line 193 by the expression self._ext_to_normal(_getfinalpathname(s)), the path returned at line 201 will be joined from the absolute, resolved part and the unresolved remained.
If none of the components get resolved then the path will be returned at line 199 as passed into the function.
History
Date User Action Args
2017-12-27 20:13:36mliskasetrecipients: + mliska
2017-12-27 20:13:36mliskasetmessageid: <1514405616.88.0.213398074469.issue32434@psf.upfronthosting.co.za>
2017-12-27 20:13:36mliskalinkissue32434 messages
2017-12-27 20:13:36mliskacreate