]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-150880: Clarify DirEntry.path construction semantics (GH-153218)
authorZain Nadeem <zainnadeemzainnadeem80@gmail.com>
Mon, 6 Jul 2026 17:14:28 +0000 (22:14 +0500)
committerGitHub <noreply@github.com>
Mon, 6 Jul 2026 17:14:28 +0000 (17:14 +0000)
Doc/library/os.rst

index 6331ba4a034c5c6d9149da56ad03a0c4fbe32c54..5858d9733c57796d95e57d3a0a06ca2777a1519d 100644 (file)
@@ -3037,10 +3037,16 @@ features:
 
    .. attribute:: path
 
-      The entry's full path name: equivalent to ``os.path.join(scandir_path,
-      entry.name)`` where *scandir_path* is the :func:`scandir` *path*
-      argument.  The path is only absolute if the :func:`scandir` *path*
-      argument was absolute.  If the :func:`scandir` *path*
+      The entry's path name: equivalent to ``os.path.join(scandir_path,
+      entry.name)`` where *scandir_path* is the original :func:`scandir`
+      *path* argument.  Apart from the filename, the path preserves the
+      original :func:`scandir` argument.  If the :func:`scandir` *path*
+      argument was relative, the :attr:`path` attribute is also relative.
+      Changing the current working directory after creating the
+      :func:`scandir` iterator may cause later uses of :attr:`path` to resolve
+      differently.  On some platforms, the constructed path may not be valid
+      if the original :func:`scandir` argument was usable for enumeration but
+      not for joining with the entry name.  If the :func:`scandir` *path*
       argument was a :ref:`file descriptor <path_fd>`, the :attr:`path`
       attribute is the same as the :attr:`name` attribute.