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 eryksun
Recipients akima, eryksun, pitrou, serhiy.storchaka, steve.dower
Date 2021-02-25.17:05:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1614272714.4.0.71845296951.issue22302@roundup.psfhosted.org>
In-reply-to
Content
> 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.)
History
Date User Action Args
2021-02-25 17:05:14eryksunsetrecipients: + eryksun, pitrou, serhiy.storchaka, steve.dower, akima
2021-02-25 17:05:14eryksunsetmessageid: <1614272714.4.0.71845296951.issue22302@roundup.psfhosted.org>
2021-02-25 17:05:14eryksunlinkissue22302 messages
2021-02-25 17:05:14eryksuncreate