diff options
author | domragusa <64558788+domragusa@users.noreply.github.com> | 2022-10-28 23:20:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-28 23:20:14 (GMT) |
commit | e089f23bbbb27a84c6354147b99f7ec897ca9925 (patch) | |
tree | c90fd2f1187d725ba7839eef4cc3f1429b9fa574 /Misc/ACKS | |
parent | 72fa57a8fe2e9df637170dc97f994ac70931e8e9 (diff) | |
download | cpython-e089f23bbbb27a84c6354147b99f7ec897ca9925.zip cpython-e089f23bbbb27a84c6354147b99f7ec897ca9925.tar.gz cpython-e089f23bbbb27a84c6354147b99f7ec897ca9925.tar.bz2 |
gh-84538: add strict argument to pathlib.PurePath.relative_to (GH-19813)
By default, :meth:`pathlib.PurePath.relative_to` doesn't deal with paths that are not a direct prefix of the other, raising an exception in that instance. This change adds a *walk_up* parameter that can be set to allow for using ``..`` to calculate the relative path.
example:
```
>>> p = PurePosixPath('/etc/passwd')
>>> p.relative_to('/etc')
PurePosixPath('passwd')
>>> p.relative_to('/usr')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pathlib.py", line 940, in relative_to
raise ValueError(error_message.format(str(self), str(formatted)))
ValueError: '/etc/passwd' does not start with '/usr'
>>> p.relative_to('/usr', strict=False)
PurePosixPath('../etc/passwd')
```
https://bugs.python.org/issue40358
Automerge-Triggered-By: GH:brettcannon
Diffstat (limited to 'Misc/ACKS')
-rw-r--r-- | Misc/ACKS | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -1440,6 +1440,7 @@ Pierre Quentel Brian Quinlan Anders Qvist Thomas Rachel +Domenico Ragusa Ram Rachum Jeffrey Rackauckas Jérôme Radix |