Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Closed
Description
pathlib.PurePath.relative_to(other, walk_up=True) doesn't handle '..' segments in itsother argument correctly:
>>>frompathlibimportPurePath,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 raisingValueError is the only reasonable thing to do.