[issue36860] Inconsistent/Undocumented behavior with pathlib resolve and absolute on Windows

2021-03-21 Thread Eryk Sun


Eryk Sun  added the comment:

The issue with non-strict resolution of relative paths that do not exist is 
being addressed in bpo-38671. The proposal to support and document the 
absolute() method is addressed in bpo-29688.

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> pathlib.Path.resolve(strict=False) returns relative path on 
Windows if the entry does not exist

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36860] Inconsistent/Undocumented behavior with pathlib resolve and absolute on Windows

2019-05-09 Thread Eryk Sun


Eryk Sun  added the comment:

Windows resolve() is based on ntpath._getfinalpathname, which requires that the 
file exists and is accessible. resolve() defaults to non-strict behavior, which 
tries to resolve as much as possible by traversing the path in reverse and 
trying _getfinalpathname until it succeeds. For this to work reliably, it needs 
to begin with a fully-qualified path from ntpath._getfullpathname. This is also 
required in order to correctly resolve paths that have a reserved DOS device 
name in the final component (e.g. "nul", "nul:", "nul.txt")

Additionally, for an empty path, resolve() returns os.getcwd(). I don't know 
whether this case occurs in practice, but the working directory has to be 
resolved in Windows the same as any other path. It's not already resolved.

Also, the non-strict case should be relaxed like the POSIX version. It should 
continue resolving the path on any OSError, with possibly one exception. The 
POSIX version raises RuntimeError for a symlink loop. In Windows this case is 
ERROR_CANT_RESOLVE_FILENAME (1921). For cross-platform compatibility, this 
should probably be handled by raising the same RuntimeError.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36860] Inconsistent/Undocumented behavior with pathlib resolve and absolute on Windows

2019-05-08 Thread Alex


New submission from Alex :

Maybe I am doing something wrong here but:

On Windows 10:
> python --version
Python 3.7.1
> python 
>>> from pathlib import Path
>>> Path("test.py").resolve()
WindowsPath('test.py')
>>> Path("test.py").absolute()  # this is undocumented in 
>>> https://docs.python.org/3.7/library/pathlib.html
WindowsPath('C:/Users/Name/Desktop/test.py')

On Ubuntu 18.04 LTS:
$ python3.7 --version
Python 3.7.3
$ python3.7
>>> from pathlib import Path
>>> Path("test.py").resolve()
PosixPath('/home/name/test.py')
>>> Path("test.py").absolute()  # same as above undocumented
PosixPath('/home/name/test.py')

Why in Windows does this fail, but not Linux? Why is .absolute() undocumented? 
I've looked around trying to figure out what the intended behavior is but there 
is conflicting information.

Resolve seems to not work correctly on Windows. Bug?

--
components: Library (Lib), Windows
messages: 341953
nosy: alexjacobson95, eryksun, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Inconsistent/Undocumented behavior with pathlib resolve and absolute on 
Windows
type: behavior
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com