cpython/Doc/whatsnew
domragusa e089f23bbb
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
2022-10-28 16:20:14 -07:00
..
2.0.rst gh-96959: Update more HTTP links (GH-97536) 2022-09-27 14:08:11 +03:00
2.1.rst gh-93851: Fix all broken links in Doc/ (GH-93853) 2022-06-21 20:55:18 +02:00
2.2.rst docs: Change links to label refs (#98454) 2022-10-25 20:26:28 -07:00
2.3.rst gh-93738: Documentation C syntax (:c:type:<C type> -> :c:expr:<C type>) (#97768) 2022-10-05 11:01:14 -07:00
2.4.rst gh-93738: Documentation C syntax (:c:type:<C type> -> :c:expr:<C type>) (#97768) 2022-10-05 11:01:14 -07:00
2.5.rst gh-93738: Disallow pre-v3 syntax in the C domain (#97962) 2022-10-06 10:11:37 -07:00
2.6.rst Docs: Fix backtick errors found by sphinx-lint (#97998) 2022-10-06 18:01:30 -07:00
2.7.rst Docs: Fix backtick errors found by sphinx-lint (#97998) 2022-10-06 18:01:30 -07:00
3.0.rst Docs: remove redundant "adverb-adjective" hyphens from compound modifiers (GH-94551) 2022-07-05 11:16:10 +02:00
3.1.rst gh-96959: Update HTTP links which are redirected to HTTPS (GH-96961) 2022-09-24 14:38:53 +03:00
3.2.rst Docs: Fix backtick errors found by sphinx-lint (#97998) 2022-10-06 18:01:30 -07:00
3.3.rst Docs: Fix backtick errors found by sphinx-lint (#97998) 2022-10-06 18:01:30 -07:00
3.4.rst gh-96959: Update more HTTP links (GH-97536) 2022-09-27 14:08:11 +03:00
3.5.rst Docs: Fix backtick errors found by sphinx-lint (#97998) 2022-10-06 18:01:30 -07:00
3.6.rst docs: Change links to label refs (#98454) 2022-10-25 20:26:28 -07:00
3.7.rst Docs: Fix backtick errors found by sphinx-lint (#97998) 2022-10-06 18:01:30 -07:00
3.8.rst docs: Change links to label refs (#98454) 2022-10-25 20:26:28 -07:00
3.9.rst Docs: Fix backtick errors found by sphinx-lint (#97998) 2022-10-06 18:01:30 -07:00
3.10.rst Doc: Remove title text from internal links (#98409) 2022-10-19 08:36:07 -07:00
3.11.rst fix a typo in whatsnew/3.11 (#98603) 2022-10-25 16:42:54 -07:00
3.12.rst gh-84538: add strict argument to pathlib.PurePath.relative_to (GH-19813) 2022-10-28 16:20:14 -07:00
changelog.rst
index.rst Fix What's New for 3.12 (GH-92482) 2022-05-08 18:23:08 +03:00