Skip to content

Commit b5c0284

Browse files
dura0okcursoragent
andcommitted
gh-154690: Narrow ensure_distinct_paths() resolve() exception handling
Only catch AttributeError (no resolve on virtual paths) and OSError (realpath failure), with a comment explaining each case. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent d228788 commit b5c0284

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Lib/pathlib/_os.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,9 @@ def ensure_distinct_paths(source, target):
275275
try:
276276
source = source.resolve(strict=False)
277277
target = target.resolve(strict=False)
278-
except (AttributeError, TypeError):
279-
pass
280-
except (OSError, ValueError, RuntimeError, NotImplementedError):
278+
except (AttributeError, OSError):
279+
# AttributeError: path type has no resolve() (e.g. virtual zip paths).
280+
# OSError: os.path.realpath() failed; keep comparing lexically.
281281
pass
282282
if source == target:
283283
err = OSError(EINVAL, "Source and target are the same path")

0 commit comments

Comments
 (0)