This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: pathlib relative_to behaviour change
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.10
Status: closed Resolution: duplicate
Dependencies: Superseder: pathlib's relative_to should behave like os.path.relpath
View: 40358
Assigned To: Nosy List: Socob, armins.bagrats, barneygale
Priority: normal Keywords:

Created on 2020-11-01 15:48 by armins.bagrats, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg380148 - (view) Author: Armins Stepanjans (armins.bagrats) Date: 2020-11-01 15:48
In the docs ( PurePath.relative_to() is specified to fail for arguments that are not on the original path (e.g. Path('/ham/beans').relative_to(Path('/spam'))).

I believe it would be useful to extend the behaviour of relative_to so that it handles the case above. For example, I would expect Path('/ham/beans').relative_to(Path('/spam')) to return Path('../ham/beans').

If this sounds like a useful change I'd be happy to make a PR for it.
msg393774 - (view) Author: Barney Gale (barneygale) * Date: 2021-05-17 00:19
That does sound pretty useful! I'd be happy to review a PR though I'm not a core dev.
msg393776 - (view) Author: Barney Gale (barneygale) * Date: 2021-05-17 00:54
In fact, I think this is a duplicate of issue40358, which has an open PR against it.
Date User Action Args
2022-04-11 14:59:37adminsetgithub: 86400
2022-02-22 23:52:02Socobsetnosy: + Socob
2021-06-23 10:41:51serhiy.storchakasetstatus: open -> closed
superseder: pathlib's relative_to should behave like os.path.relpath
resolution: duplicate
stage: resolved
2021-05-17 00:54:45barneygalesetmessages: + msg393776
2021-05-17 00:19:20barneygalesetnosy: + barneygale
messages: + msg393774
2020-11-01 15:48:23armins.bagratscreate