Message387634
@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')
>>>
``` |
|
Date |
User |
Action |
Args |
2021-02-24 17:40:07 | John-Hennig | set | recipients:
+ John-Hennig, brett.cannon, paul.moore, docs@python, veky, ChrisBarker, 45757, florisla |
2021-02-24 17:40:07 | John-Hennig | set | messageid: <1614188407.48.0.291286878478.issue39090@roundup.psfhosted.org> |
2021-02-24 17:40:07 | John-Hennig | link | issue39090 messages |
2021-02-24 17:40:06 | John-Hennig | create | |
|