Eryk Sun <eryk...@gmail.com> added the comment:

> figure out whether to do `Path.cwd() / path`

Thus a UNC path is absolute, i.e. any path that starts with 2 or more slashes, 
and all other paths are relative unless they have both a drive and a root. For 
example:

    def isabs(s):
        """Test whether a path is absolute"""
        s = os.fspath(s)
        seps = _get_bothseps(s)
        if len(s) > 1 and s[0] in seps and s[1] in seps:
            return True
        drive, rest = splitdrive(s)
        if drive and rest:
            return rest[0] in seps
        return False

This also fixes the mistaken result that a rooted path such as "/spam" is 
absolute. When opened directly, a rooted path is relative to the drive of the 
current working directory. When accessed indirectly as the target of a symlink, 
a rooted path is relative to the volume device of the opened path. 

An example of the latter is a symlink named "link" that targets "\". If it's 
accessed as E:\link, it resolves to E:\. If it's accessed as 
C:\Mount\VolumeE\link, it resolves instead to C:\. The relative link resolves 
differently depending on the path traversed to access it. (Note that when 
resolving the target of a relative symlink, mountpoints such as "VolumeE" that 
are traversed in the opened path do not get replaced by their target path, 
unlike directory symlinks, which do get replaced by their target path. This 
behavior is basically the same as the way mountpoints and symlinks are handled 
in Unix.)

----------
versions: +Python 3.10, Python 3.9 -Python 2.7, Python 3.5, Python 3.6, Python 
3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue22302>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to