Skip to content

Commit c0293f9

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

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
@@ -2907,10 +2907,16 @@ features:
29072907

29082908
.. attribute:: path
29092909

2910-
The entry's full path name: equivalent to ``os.path.join(scandir_path,
2911-
entry.name)`` where *scandir_path* is the :func:`scandir` *path*
2912-
argument. The path is only absolute if the :func:`scandir` *path*
2913-
argument was absolute. If the :func:`scandir` *path*
2910+
The entry's path name: equivalent to ``os.path.join(scandir_path,
2911+
entry.name)`` where *scandir_path* is the original :func:`scandir`
2912+
*path* argument. Apart from the filename, the path preserves the
2913+
original :func:`scandir` argument. If the :func:`scandir` *path*
2914+
argument was relative, the :attr:`path` attribute is also relative.
2915+
Changing the current working directory after creating the
2916+
:func:`scandir` iterator may cause later uses of :attr:`path` to resolve
2917+
differently. On some platforms, the constructed path may not be valid
2918+
if the original :func:`scandir` argument was usable for enumeration but
2919+
not for joining with the entry name. If the :func:`scandir` *path*
29142920
argument was a :ref:`file descriptor <path_fd>`, the :attr:`path`
29152921
attribute is the same as the :attr:`name` attribute.
29162922

0 commit comments

Comments
 (0)