https://github.com/python/cpython/commit/32a0aa89d5e212fa86e1e7fae9b81efa11f2f598
commit: 32a0aa89d5e212fa86e1e7fae9b81efa11f2f598
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: hugovk <[email protected]>
date: 2026-09-24T17:05:11+03:00
summary:
[3.15] gh-140971: Document pathlib.PurePath("") meaning and bool value
(GH-157293) (#157943)
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 45b5797058f623..04b1bd01af1187 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`)::
@@ -1040,8 +1041,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
@@ -1049,6 +1050,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]