Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix wording in documentation as requested
  • Loading branch information
domragusa committed May 17, 2021
commit 029c3d5ce9acb7dc1bfc8e2b9cce1e0e54cc0b51
11 changes: 8 additions & 3 deletions Doc/library/pathlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -563,12 +563,17 @@ Pure paths provide the following methods and properties:
raise ValueError(error_message.format(str(self), str(formatted)))
ValueError: '/etc/passwd' is not on the same drive as 'foo' OR one path is relative and the other is absolute.

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.
In strict mode (the default), the path must start with *other*. In non-strict
mode, ``..`` entries may be added to form the relative path. In all other
cases, such as the paths referencing different drives, :exe:`ValueError` is
raised.

.. warning::
Non-strict mode assumes that no symlinks are present in the path; you
should call :meth:`~Path.resolve` first to ensure this.

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


.. method:: PurePath.with_name(name)
Expand Down
7 changes: 7 additions & 0 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ New Modules
Improved Modules
================

pathlib
-------

:meth:`pathlib.PurePath.relative_to` now supports generating relative paths
containing ``..`` entries if its new *strict* keyword-only argument is set to
``False``. The new behavior is more consistent with :func:`os.path.relpath`.
(Contributed by Domenico Ragusa in :issue:`40358`.)

Optimizations
=============
Expand Down