diff options
author | Barney Gale <barney.gale@gmail.com> | 2021-04-28 15:50:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-28 15:50:17 (GMT) |
commit | baecfbd849dbf42360d3a84af6cc13160838f24d (patch) | |
tree | 5d82a6504cd2859197e1bcd81ceaecef035a6aad /Doc/library/os.path.rst | |
parent | 859577c24981d6b36960d309f99f7fc810fe75c2 (diff) | |
download | cpython-baecfbd849dbf42360d3a84af6cc13160838f24d.zip cpython-baecfbd849dbf42360d3a84af6cc13160838f24d.tar.gz cpython-baecfbd849dbf42360d3a84af6cc13160838f24d.tar.bz2 |
bpo-43757: Make pathlib use os.path.realpath() to resolve symlinks in a path (GH-25264)
Also adds a new "strict" argument to realpath() to avoid changing the default behaviour of pathlib while sharing the implementation.
Diffstat (limited to 'Doc/library/os.path.rst')
-rw-r--r-- | Doc/library/os.path.rst | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst index 4cab311..d06d9ce 100644 --- a/Doc/library/os.path.rst +++ b/Doc/library/os.path.rst @@ -344,15 +344,24 @@ the :mod:`glob` module.) Accepts a :term:`path-like object`. -.. function:: realpath(path) +.. function:: realpath(path, *, strict=False) Return the canonical path of the specified filename, eliminating any symbolic links encountered in the path (if they are supported by the operating system). + If a path doesn't exist or a symlink loop is encountered, and *strict* is + ``True``, :exc:`OSError` is raised. If *strict* is ``False``, the path is + resolved as far as possible and any remainder is appended without checking + whether it exists. + .. note:: - When symbolic link cycles occur, the returned path will be one member of - the cycle, but no guarantee is made about which member that will be. + This function emulates the operating system's procedure for making a path + canonical, which differs slightly between Windows and UNIX with respect + to how links and subsequent path components interact. + + Operating system APIs make paths canonical as needed, so it's not + normally necessary to call this function. .. versionchanged:: 3.6 Accepts a :term:`path-like object`. @@ -360,6 +369,9 @@ the :mod:`glob` module.) .. versionchanged:: 3.8 Symbolic links and junctions are now resolved on Windows. + .. versionchanged:: 3.10 + The *strict* parameter was added. + .. function:: relpath(path, start=os.curdir) |