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 John-Hennig
Recipients 45757, ChrisBarker, John-Hennig, brett.cannon, docs@python, florisla, paul.moore, veky
Date 2021-02-24.17:40:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1614188407.48.0.291286878478.issue39090@roundup.psfhosted.org>
In-reply-to
Content
@Floris:
> Not mentioning Path.resolve()'s behavior w.r.t. non-existing files since
that's documented in resolve() itself.

I don't see it mentioned in the documentation of `resolve()`, or anywhere else in the docs, that on Windows (but not on other platforms) `resolve()` does *not* resolve a relative path to an absolute path if the file does not exist. As opposed to `absolute()`, which works as expected on any platform.

Linux:
```
Python 3.6.9 (default, Oct  8 2020, 12:12:24)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pathlib import Path
>>> file = Path('new.txt')
>>> file.exists()
False
>>> file.resolve()
PosixPath('/home/user/new.txt')
```

Windows:
```
Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pathlib import Path
>>> file = Path('new.txt')
>>> file.exists()
False
>>> file.resolve()
WindowsPath('new.txt')
>>> file.absolute()
WindowsPath('d:/home/new.txt')
>>> file.touch()
>>> file.resolve()
WindowsPath('D:/home/new.txt')
>>> file.unlink()
>>> file.resolve()
WindowsPath('new.txt')
>>>
```
History
Date User Action Args
2021-02-24 17:40:07John-Hennigsetrecipients: + John-Hennig, brett.cannon, paul.moore, docs@python, veky, ChrisBarker, 45757, florisla
2021-02-24 17:40:07John-Hennigsetmessageid: <1614188407.48.0.291286878478.issue39090@roundup.psfhosted.org>
2021-02-24 17:40:07John-Henniglinkissue39090 messages
2021-02-24 17:40:06John-Hennigcreate