Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add comment to _ensure_distinct_path()
  • Loading branch information
barneygale committed Aug 13, 2024
commit f58c07a9fc77584b9faf2b0de3ec2d6cdddffd96
5 changes: 5 additions & 0 deletions Lib/pathlib/_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,11 @@ def _ensure_distinct_path(self, other_path):
"""
Raise OSError(EINVAL) if the other path is within this path.
"""
# Note: there is no straightforward, foolproof algorithm to determine
# if one directory is within another. A particularly perverse example:
# consider a single network share mounted in one location via NFS, and
# in another location via CIFS. This method simply checks whether the
# other_path is lexically equal to, or within, this path.
Comment thread
picnixz marked this conversation as resolved.
Outdated
if self == other_path:
err = OSError(EINVAL, "Source and target are the same path")
elif self in other_path.parents:
Expand Down