[issue20012] Re: Allow Path.relative_to() to accept non-ancestor paths

2021-06-23 Thread Antony Lee
Change by Antony Lee : -- nosy: -Antony.Lee ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue20012] Re: Allow Path.relative_to() to accept non-ancestor paths

2021-06-23 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> pathlib's relative_to should behave like os.path.relpath ___ Python tracker

[issue20012] Re: Allow Path.relative_to() to accept non-ancestor paths

2021-06-23 Thread Janus
Janus added the comment: This issue is being addressed in #40358 which has open PR for v3.11 -- nosy: +Japanuspus ___ Python tracker ___

[issue20012] Re: Allow Path.relative_to() to accept non-ancestor paths

2016-03-23 Thread Antony Lee
Antony Lee added the comment: Kindly bumping the issue. I'd suggest overriding `PurePath.relative_to` in the `Path` class, to something like `PurePath.relative_to(self, other, *, allow_ancestor=False): ...`, which would resolve each ancestor of `self` successively to check whether it is also

[issue20012] Re: Allow Path.relative_to() to accept non-ancestor paths

2014-01-09 Thread Alexander Boyd
Alexander Boyd added the comment: Then perhaps the docstring of relative_to could note this (like relpath does), or a separate method that's explicitly not symlink safe created. Or better yet, what about a function that does (or at least tries to) give the correct answer in the face of

[issue20012] Re: Allow Path.relative_to() to accept non-ancestor paths

2013-12-18 Thread Antoine Pitrou
Antoine Pitrou added the comment: That's by design. If /etc is a symlink to e.g. /mnt/etc, the proposed result is wrong. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20012 ___

[issue20012] Re: Allow Path.relative_to() to accept non-ancestor paths

2013-12-17 Thread Anurag Kulkarni
Anurag Kulkarni added the comment: Hey! A few changes are required to accomplish what you seek, but results could be severe. Path.relative_to() should return an exception if relative path is not part of the original path. However, I have got a solution for that. I am not that familiar with