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
pathlib.PurePath.relative_to(other, walk_up=True)doesn't handle '..' segments in its other argument correctly:PurePathobjects do not know the current working directory, nor can they safely eliminate..segments without resolving symlinks, so I think raisingValueErroris the only reasonable thing to do.Linked PRs