https://github.com/python/cpython/commit/c2e4d42a4cd2640d38670551312dd1e0e05256b2
commit: c2e4d42a4cd2640d38670551312dd1e0e05256b2
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: terryjreedy <[email protected]>
date: 2026-09-22T11:45:01Z
summary:

[3.14] gh-140971: Document pathlib.PurePath("") meaning and bool value 
(GH-157293) (#157944)

gh-140971: Document pathlib.PurePath("") meaning and bool value (GH-157293)

pathlib.PurePath() and pathlib.PurePath('') both mean the
current working directory and both have boolean value True.

Patch implements suggestion in
https://github.com/python/cpython/pull/140993#discussion_r2490858118.
---------
(cherry picked from commit c36aa097768eb78cce371d975d173bd04060db56)

Co-authored-by: Terry Jan Reedy <[email protected]>
Co-authored-by: LiuQhahah <[email protected]>

files:
M Doc/library/pathlib.rst

diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst
index 792cd255753c5b..ff718f3562d24b 100644
--- a/Doc/library/pathlib.rst
+++ b/Doc/library/pathlib.rst
@@ -131,10 +131,11 @@ we also call *flavours*:
       >>> PurePath(Path('foo'), Path('bar'))
       PurePosixPath('foo/bar')
 
-   When *pathsegments* is empty, the current directory is assumed::
+   When *pathsegments* is empty or consists only of empty strings,
+   the current directory is assumed::
 
-      >>> PurePath()
-      PurePosixPath('.')
+      >>> PurePath(), PurePath('')
+      (PurePosixPath('.'), PurePosixPath('.'))
 
    If a segment is an absolute path, all previous segments are ignored
    (like :func:`os.path.join`)::
@@ -1054,8 +1055,8 @@ Querying file type and status
 
 .. method:: Path.exists(*, follow_symlinks=True)
 
-   Return ``True`` if the path points to an existing file or directory.
-   ``False`` will be returned if the path is invalid, inaccessible or missing.
+   Return ``True`` if the path points to an existing file or directory and
+   ``False`` if the path is invalid, inaccessible or missing.
    Use :meth:`Path.stat` to distinguish between these cases.
 
    This method normally follows symlinks; to check if a symlink exists, add
@@ -1063,6 +1064,8 @@ Querying file type and status
 
    ::
 
+      >>> Path('').exists()  # The current directory.
+      True
       >>> Path('.').exists()
       True
       >>> Path('setup.py').exists()

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to