summaryrefslogtreecommitdiffstats
path: root/Lib/pathlib
diff options
context:
space:
mode:
authorBarney Gale <barney.gale@gmail.com>2024-11-29 21:03:39 (GMT)
committerGitHub <noreply@github.com>2024-11-29 21:03:39 (GMT)
commit38264a060a8178d58046e90e9beb8220e3c22046 (patch)
tree638b08da71289b121f9dbe1e75364175d508a50e /Lib/pathlib
parent15d6506d175780bb29e5fcde654e3860408aa93e (diff)
downloadcpython-38264a060a8178d58046e90e9beb8220e3c22046.zip
cpython-38264a060a8178d58046e90e9beb8220e3c22046.tar.gz
cpython-38264a060a8178d58046e90e9beb8220e3c22046.tar.bz2
GH-127381: pathlib ABCs: remove `PathBase.lstat()` (#127382)
Remove the `PathBase.lstat()` method, which is a trivial variation of `stat()`. No user-facing changes because the pathlib ABCs are still private.
Diffstat (limited to 'Lib/pathlib')
-rw-r--r--Lib/pathlib/_abc.py12
-rw-r--r--Lib/pathlib/_local.py7
2 files changed, 9 insertions, 10 deletions
diff --git a/Lib/pathlib/_abc.py b/Lib/pathlib/_abc.py
index 2c243d4..697f329 100644
--- a/Lib/pathlib/_abc.py
+++ b/Lib/pathlib/_abc.py
@@ -438,14 +438,6 @@ class PathBase(PurePathBase):
"""
raise UnsupportedOperation(self._unsupported_msg('stat()'))
- def lstat(self):
- """
- Like stat(), except if the path points to a symlink, the symlink's
- status information is returned, rather than its target's.
- """
- return self.stat(follow_symlinks=False)
-
-
# Convenience functions for querying the stat results
def exists(self, *, follow_symlinks=True):
@@ -505,7 +497,7 @@ class PathBase(PurePathBase):
Whether this path is a symbolic link.
"""
try:
- return S_ISLNK(self.lstat().st_mode)
+ return S_ISLNK(self.stat(follow_symlinks=False).st_mode)
except (OSError, ValueError):
return False
@@ -789,7 +781,7 @@ class PathBase(PurePathBase):
def lstat(path_str):
path = self.with_segments(path_str)
path._resolving = True
- return path.lstat()
+ return path.stat(follow_symlinks=False)
def readlink(path_str):
path = self.with_segments(path_str)
diff --git a/Lib/pathlib/_local.py b/Lib/pathlib/_local.py
index b27f456..25c1e3f 100644
--- a/Lib/pathlib/_local.py
+++ b/Lib/pathlib/_local.py
@@ -542,6 +542,13 @@ class Path(PathBase, PurePath):
"""
return os.stat(self, follow_symlinks=follow_symlinks)
+ def lstat(self):
+ """
+ Like stat(), except if the path points to a symlink, the symlink's
+ status information is returned, rather than its target's.
+ """
+ return os.lstat(self)
+
def exists(self, *, follow_symlinks=True):
"""
Whether this path exists.