Skip to content

Commit 9d603d3

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

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
@@ -3037,10 +3037,16 @@ features:
30373037

30383038
.. attribute:: path
30393039

3040-
The entry's full path name: equivalent to ``os.path.join(scandir_path,
3041-
entry.name)`` where *scandir_path* is the :func:`scandir` *path*
3042-
argument. The path is only absolute if the :func:`scandir` *path*
3043-
argument was absolute. If the :func:`scandir` *path*
3040+
The entry's path name: equivalent to ``os.path.join(scandir_path,
3041+
entry.name)`` where *scandir_path* is the original :func:`scandir`
3042+
*path* argument. Apart from the filename, the path preserves the
3043+
original :func:`scandir` argument. If the :func:`scandir` *path*
3044+
argument was relative, the :attr:`path` attribute is also relative.
3045+
Changing the current working directory after creating the
3046+
:func:`scandir` iterator may cause later uses of :attr:`path` to resolve
3047+
differently. On some platforms, the constructed path may not be valid
3048+
if the original :func:`scandir` argument was usable for enumeration but
3049+
not for joining with the entry name. If the :func:`scandir` *path*
30443050
argument was a :ref:`file descriptor <path_fd>`, the :attr:`path`
30453051
attribute is the same as the :attr:`name` attribute.
30463052

0 commit comments

Comments
 (0)