Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-40486: Specify what happens if directory content change diring iteration #22025

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion Doc/library/glob.rst
Expand Up @@ -43,7 +43,9 @@ For example, ``'[?]'`` matches the character ``'?'``.
(like :file:`/usr/src/Python-1.5/Makefile`) or relative (like
:file:`../../Tools/\*/\*.gif`), and can contain shell-style wildcards. Broken
symlinks are included in the results (as in the shell). Whether or not the
results are sorted depends on the file system.
results are sorted depends on the file system. If a file that satisfies
conditions is removed or added during the call of this function, whether
a path name for that file be included is unspecified.

If *root_dir* is not ``None``, it should be a :term:`path-like object`
specifying the root directory for searching. It has the same effect on
Expand Down
11 changes: 9 additions & 2 deletions Doc/library/os.rst
Expand Up @@ -1852,6 +1852,8 @@ features:
Return a list containing the names of the entries in the directory given by
*path*. The list is in arbitrary order, and does not include the special
entries ``'.'`` and ``'..'`` even if they are present in the directory.
If a file is removed from or added to the directory during the call of
this function, whether a name for that file be included is unspecified.

*path* may be a :term:`path-like object`. If *path* is of type ``bytes``
(directly or indirectly through the :class:`PathLike` interface),
Expand Down Expand Up @@ -2257,7 +2259,9 @@ features:
Return an iterator of :class:`os.DirEntry` objects corresponding to the
entries in the directory given by *path*. The entries are yielded in
arbitrary order, and the special entries ``'.'`` and ``'..'`` are not
included.
included. If a file is removed from or added to the directory after
creating the iterator, whether an entry for that file be included is
unspecified.

Using :func:`scandir` instead of :func:`listdir` can significantly
increase the performance of code that also needs file type or file
Expand Down Expand Up @@ -3007,7 +3011,10 @@ features:
*filenames* is a list of the names of the non-directory files in *dirpath*.
Note that the names in the lists contain no path components. To get a full path
(which begins with *top*) to a file or directory in *dirpath*, do
``os.path.join(dirpath, name)``.
``os.path.join(dirpath, name)``. Whether or not the lists are sorted
depends on the file system. If a file is removed from or added to the
*dirpath* directory during generating the lists, whether a name for that
file be included is unspecified.

If optional argument *topdown* is ``True`` or not specified, the triple for a
directory is generated before the triples for any of its subdirectories
Expand Down
5 changes: 5 additions & 0 deletions Doc/library/pathlib.rst
Expand Up @@ -890,6 +890,11 @@ call fails (for example because the path doesn't exist).
PosixPath('docs/_static')
PosixPath('docs/Makefile')

The children are yielded in arbitrary order, and the special entries
``'.'`` and ``'..'`` are not included. If a file is removed from or added
to the directory after creating the iterator, whether an path object for
that file be included is unspecified.

.. method:: Path.lchmod(mode)

Like :meth:`Path.chmod` but, if the path points to a symbolic link, the
Expand Down