summaryrefslogtreecommitdiffstats
path: root/Lib/ntpath.py
diff options
context:
space:
mode:
authorBarney Gale <barney.gale@gmail.com>2021-04-28 15:50:17 (GMT)
committerGitHub <noreply@github.com>2021-04-28 15:50:17 (GMT)
commitbaecfbd849dbf42360d3a84af6cc13160838f24d (patch)
tree5d82a6504cd2859197e1bcd81ceaecef035a6aad /Lib/ntpath.py
parent859577c24981d6b36960d309f99f7fc810fe75c2 (diff)
downloadcpython-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 'Lib/ntpath.py')
-rw-r--r--Lib/ntpath.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index 5ae8079..527c7ae 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -635,7 +635,7 @@ else:
tail = join(name, tail) if tail else name
return tail
- def realpath(path):
+ def realpath(path, *, strict=False):
path = normpath(path)
if isinstance(path, bytes):
prefix = b'\\\\?\\'
@@ -660,6 +660,8 @@ else:
path = _getfinalpathname(path)
initial_winerror = 0
except OSError as ex:
+ if strict:
+ raise
initial_winerror = ex.winerror
path = _getfinalpathname_nonstrict(path)
# The path returned by _getfinalpathname will always start with \\?\ -