gh-84538: add strict argument to pathlib.PurePath.relative_to by domragusa · Pull Request #19813 · python/cpython

Conversation

domragusa

CuriousLearner

@domragusa domragusa changed the title bpo-40358: add strict param to pathlib.PurePath.relative_to bpo-40358: add strict argument to pathlib.PurePath.relative_to

May 28, 2020

terryjreedy

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>

barneygale

.. versionadded:: 3.11
The *strict* argument (pre-3.11 behavior is strict).
.. versionadded:: 3.10
The *strict* argument (pre-3.10 behavior is strict).

NOTE: This function is part of :class:`PurePath` and works with strings. It does not check or access the underlying file structure.
If the path doesn't start with *other* and *strict* is ``True``, :exc:`ValueError` is raised. If *strict* is ``False`` and one path is relative and the other is absolute or if they reference different drives :exc:`ValueError` is raised.

domragusa

.. versionadded:: 3.11
The *strict* argument (pre-3.11 behavior is strict).
.. versionadded:: 3.10
The *strict* argument (pre-3.10 behavior is strict).

barneygale

When *walk_up* is False, the default, the path must start with *other*,
when it's True ``..`` entries may be added to form the relative path. In
all other cases, such as the paths referencing different drives,
:exc:`ValueError` is raised.
Co-authored-by: Brett Cannon <brett@python.org>

CAM-Gerlach

Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>

brettcannon

@brettcannon brettcannon changed the title bpo-40358: add strict argument to pathlib.PurePath.relative_to gh-84538: add strict argument to pathlib.PurePath.relative_to

Oct 28, 2022