Skip to content

gh-146646: Document that glob functions suppress OSError#147996

Open
WYSIATI wants to merge 1 commit intopython:mainfrom
WYSIATI:doc-glob-oserror-suppression
Open

gh-146646: Document that glob functions suppress OSError#147996
WYSIATI wants to merge 1 commit intopython:mainfrom
WYSIATI:doc-glob-oserror-suppression

Conversation

@WYSIATI
Copy link
Copy Markdown

@WYSIATI WYSIATI commented Apr 2, 2026

Summary

  • Add notes to glob.glob() and glob.iglob() documentation that OSError exceptions raised from scanning the filesystem are silently suppressed
  • This includes PermissionError when accessing directories without read permission
  • The pathlib.Path.glob() docs already document this behavior (added in 3.13 via a versionchanged note), but the glob module docs did not mention it

As @vstinner noted in the issue, the glob module ignores all OSError errors (not just access errors) — for example, _iterdir() wraps its scanner in except OSError: return.


📚 Documentation preview 📚: https://cpython-previews--147996.org.readthedocs.build/

Document that glob.glob() and glob.iglob() silently suppress any
OSError exceptions raised while scanning the filesystem, such as
PermissionError when accessing directories without read permission.

The pathlib.Path.glob() docs already note this behavior (added in 3.13),
but the glob module docs did not mention it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant