Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bd078df

Browse filesBrowse files
[3.9] bpo-40486: Specify what happens if directory content change diring iteration (GH-22025) (GH-22093)
(cherry picked from commit 306cfb3) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 78ef1b6 commit bd078df
Copy full SHA for bd078df

File tree

Expand file treeCollapse file tree

3 files changed

+17
-3
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+17
-3
lines changed

‎Doc/library/glob.rst

Copy file name to clipboardExpand all lines: Doc/library/glob.rst
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ For example, ``'[?]'`` matches the character ``'?'``.
4343
(like :file:`/usr/src/Python-1.5/Makefile`) or relative (like
4444
:file:`../../Tools/\*/\*.gif`), and can contain shell-style wildcards. Broken
4545
symlinks are included in the results (as in the shell). Whether or not the
46-
results are sorted depends on the file system.
46+
results are sorted depends on the file system. If a file that satisfies
47+
conditions is removed or added during the call of this function, whether
48+
a path name for that file be included is unspecified.
4749

4850
.. index::
4951
single: **; in glob-style wildcards

‎Doc/library/os.rst

Copy file name to clipboardExpand all lines: Doc/library/os.rst
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,8 @@ features:
18371837
Return a list containing the names of the entries in the directory given by
18381838
*path*. The list is in arbitrary order, and does not include the special
18391839
entries ``'.'`` and ``'..'`` even if they are present in the directory.
1840+
If a file is removed from or added to the directory during the call of
1841+
this function, whether a name for that file be included is unspecified.
18401842

18411843
*path* may be a :term:`path-like object`. If *path* is of type ``bytes``
18421844
(directly or indirectly through the :class:`PathLike` interface),
@@ -2242,7 +2244,9 @@ features:
22422244
Return an iterator of :class:`os.DirEntry` objects corresponding to the
22432245
entries in the directory given by *path*. The entries are yielded in
22442246
arbitrary order, and the special entries ``'.'`` and ``'..'`` are not
2245-
included.
2247+
included. If a file is removed from or added to the directory after
2248+
creating the iterator, whether an entry for that file be included is
2249+
unspecified.
22462250

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

29973004
If optional argument *topdown* is ``True`` or not specified, the triple for a
29983005
directory is generated before the triples for any of its subdirectories

‎Doc/library/pathlib.rst

Copy file name to clipboardExpand all lines: Doc/library/pathlib.rst
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,11 @@ call fails (for example because the path doesn't exist).
890890
PosixPath('docs/_static')
891891
PosixPath('docs/Makefile')
892892

893+
The children are yielded in arbitrary order, and the special entries
894+
``'.'`` and ``'..'`` are not included. If a file is removed from or added
895+
to the directory after creating the iterator, whether an path object for
896+
that file be included is unspecified.
897+
893898
.. method:: Path.lchmod(mode)
894899

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.