-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixestopic-pathlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
pathlib.PurePath.relative_to(other, walk_up=True)
doesn't handle '..' segments in its other argument correctly:
>>> from pathlib import PurePath, Path
>>> Path.cwd()
PosixPath('/home/barney/projects/cpython')
>>> PurePath('a/b').relative_to('a/..', walk_up=True)
PurePosixPath('../b')
# expected: ValueError (ideal world: 'a/b')
>>> PurePath('a/b').relative_to('a/../..', walk_up=True)
PurePosixPath('../../b')
# expected: ValueError (ideal world: 'cpython/a/b')
PurePath
objects do not know the current working directory, nor can they safely eliminate ..
segments without resolving symlinks, so I think raising ValueError
is the only reasonable thing to do.
Linked PRs
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixestopic-pathlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error