summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-09-04 22:25:51 (GMT)
committerGitHub <noreply@github.com>2020-09-04 22:25:51 (GMT)
commite52f5bc898c9a11fb1d57a42a1f9ec60b424d576 (patch)
tree1aa5d2eec23c76a05d754a97f6d16991f91aecd6 /Doc
parent1470c9189c8b099e0be94b4d89842f5345b776ec (diff)
downloadcpython-e52f5bc898c9a11fb1d57a42a1f9ec60b424d576.zip
cpython-e52f5bc898c9a11fb1d57a42a1f9ec60b424d576.tar.gz
cpython-e52f5bc898c9a11fb1d57a42a1f9ec60b424d576.tar.bz2
[3.8] bpo-40486: Specify what happens if directory content change diring iteration (GH-22025) (GH-22094)
(cherry picked from commit 306cfb3a37e1438f6ba9f0a9f3af3c00aae4ec64) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/glob.rst4
-rw-r--r--Doc/library/os.rst11
-rw-r--r--Doc/library/pathlib.rst5
3 files changed, 17 insertions, 3 deletions
diff --git a/Doc/library/glob.rst b/Doc/library/glob.rst
index 92a8c4d..3c468eb 100644
--- a/Doc/library/glob.rst
+++ b/Doc/library/glob.rst
@@ -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.
.. index::
single: **; in glob-style wildcards
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index 77bbf99..c8e316a 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -1828,6 +1828,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),
@@ -2233,7 +2235,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
@@ -2983,7 +2987,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
diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst
index ebaedd8..c855a6e 100644
--- a/Doc/library/pathlib.rst
+++ b/Doc/library/pathlib.rst
@@ -849,6 +849,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