]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-146646: Document that glob functions suppress OSError (GH-147996) (#148288)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 9 Apr 2026 11:00:23 +0000 (13:00 +0200)
committerGitHub <noreply@github.com>
Thu, 9 Apr 2026 11:00:23 +0000 (11:00 +0000)
gh-146646: Document that glob functions suppress OSError (GH-147996)
(cherry picked from commit 8000a9de3c0b22f8202898a424c1008e13bd16ce)

Co-authored-by: WYSIATI <chester.lee.cold@gmail.com>
Doc/library/glob.rst
Doc/library/pathlib.rst
Misc/NEWS.d/next/Documentation/2026-04-02-07-20-00.gh-issue-146646.GlobDoc1.rst [new file with mode: 0644]

index 52c449281533372d1b06ac8c342aecaf95057b6e..b24e4da7bc8c0798621f0f9e5b5892d0eaf80cd2 100644 (file)
@@ -83,6 +83,11 @@ The :mod:`!glob` module defines the following functions:
       This function may return duplicate path names if *pathname*
       contains multiple "``**``" patterns and *recursive* is true.
 
+   .. note::
+      Any :exc:`OSError` exceptions raised from scanning the filesystem are
+      suppressed. This includes :exc:`PermissionError` when accessing
+      directories without read permission.
+
    .. versionchanged:: 3.5
       Support for recursive globs using "``**``".
 
@@ -106,6 +111,11 @@ The :mod:`!glob` module defines the following functions:
       This function may return duplicate path names if *pathname*
       contains multiple "``**``" patterns and *recursive* is true.
 
+   .. note::
+      Any :exc:`OSError` exceptions raised from scanning the filesystem are
+      suppressed. This includes :exc:`PermissionError` when accessing
+      directories without read permission.
+
    .. versionchanged:: 3.5
       Support for recursive globs using "``**``".
 
index 9484103e5cece425b5faee4f0ac6ff372bba0428..792cd255753c5bf793859a631885db43a1a8879c 100644 (file)
@@ -1365,6 +1365,11 @@ Reading directories
    ``False``, this method follows symlinks except when expanding "``**``"
    wildcards. Set *recurse_symlinks* to ``True`` to always follow symlinks.
 
+   .. note::
+      Any :exc:`OSError` exceptions raised from scanning the filesystem are
+      suppressed. This includes :exc:`PermissionError` when accessing
+      directories without read permission.
+
    .. audit-event:: pathlib.Path.glob self,pattern pathlib.Path.glob
 
    .. versionchanged:: 3.12
@@ -1391,6 +1396,11 @@ Reading directories
       The paths are returned in no particular order.
       If you need a specific order, sort the results.
 
+   .. note::
+      Any :exc:`OSError` exceptions raised from scanning the filesystem are
+      suppressed. This includes :exc:`PermissionError` when accessing
+      directories without read permission.
+
    .. seealso::
       :ref:`pathlib-pattern-language` and :meth:`Path.glob` documentation.
 
diff --git a/Misc/NEWS.d/next/Documentation/2026-04-02-07-20-00.gh-issue-146646.GlobDoc1.rst b/Misc/NEWS.d/next/Documentation/2026-04-02-07-20-00.gh-issue-146646.GlobDoc1.rst
new file mode 100644 (file)
index 0000000..4e89270
--- /dev/null
@@ -0,0 +1,3 @@
+Document that :func:`glob.glob`, :func:`glob.iglob`,
+:meth:`pathlib.Path.glob`, and :meth:`pathlib.Path.rglob` silently suppress
+:exc:`OSError` exceptions raised from scanning the filesystem.