Skip to content

Commit d87ee02

Browse files
[3.14] gh-150880: Clarify DirEntry.path construction semantics (GH-153218) (GH-153220)
gh-150880: Clarify DirEntry.path construction semantics (GH-153218) (cherry picked from commit 53661af) Co-authored-by: Zain Nadeem <zainnadeemzainnadeem80@gmail.com>
1 parent f2d433f commit d87ee02

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

Doc/library/os.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2980,10 +2980,16 @@ features:
29802980

29812981
.. attribute:: path
29822982

2983-
The entry's full path name: equivalent to ``os.path.join(scandir_path,
2984-
entry.name)`` where *scandir_path* is the :func:`scandir` *path*
2985-
argument. The path is only absolute if the :func:`scandir` *path*
2986-
argument was absolute. If the :func:`scandir` *path*
2983+
The entry's path name: equivalent to ``os.path.join(scandir_path,
2984+
entry.name)`` where *scandir_path* is the original :func:`scandir`
2985+
*path* argument. Apart from the filename, the path preserves the
2986+
original :func:`scandir` argument. If the :func:`scandir` *path*
2987+
argument was relative, the :attr:`path` attribute is also relative.
2988+
Changing the current working directory after creating the
2989+
:func:`scandir` iterator may cause later uses of :attr:`path` to resolve
2990+
differently. On some platforms, the constructed path may not be valid
2991+
if the original :func:`scandir` argument was usable for enumeration but
2992+
not for joining with the entry name. If the :func:`scandir` *path*
29872993
argument was a :ref:`file descriptor <path_fd>`, the :attr:`path`
29882994
attribute is the same as the :attr:`name` attribute.
29892995

0 commit comments

Comments
 (0)