gh-146646: Document that glob functions suppress OSError#147996
gh-146646: Document that glob functions suppress OSError#147996WYSIATI wants to merge 1 commit intopython:mainfrom
Conversation
vstinner
left a comment
There was a problem hiding this comment.
The issue is about pathlib.Path.glob() and pathlib.Path.rglob(). Can you also update their documentation?
Thanks @vstinner for the review, |
Doc/library/pathlib.rst
Outdated
| .. versionchanged:: 3.13 | ||
| Any :exc:`OSError` exceptions raised from scanning the filesystem are | ||
| suppressed. In previous versions, such exceptions are suppressed in many | ||
| cases, but not all. |
There was a problem hiding this comment.
Can you copy the note from the glob module to pathlib .glob() and .rglob() methods? IMO it's worth it to repeat the information (and mention PermissionError).
Doc/library/pathlib.rst
Outdated
| The paths are returned in no particular order. | ||
| If you need a specific order, sort the results. | ||
|
|
||
| .. note:: |
There was a problem hiding this comment.
I would prefer to move the note below, just before "audit-event".
There was a problem hiding this comment.
Changed, is current doc looking good to you?
4a8f892 to
9f88a5e
Compare
vstinner
left a comment
There was a problem hiding this comment.
Please avoid git push --force, it makes reviews harder to follow.
| .. seealso:: | ||
| :ref:`pathlib-pattern-language` and :meth:`Path.glob` documentation. | ||
|
|
||
| .. note:: |
There was a problem hiding this comment.
The note should be moved the seealso paragraph.
Summary
glob.glob()andglob.iglob()documentation thatOSErrorexceptions raised from scanning the filesystem are silently suppressedPermissionErrorwhen accessing directories without read permissionpathlib.Path.glob()docs already document this behavior (added in 3.13 via aversionchangednote), but theglobmodule docs did not mention itAs @vstinner noted in the issue, the
globmodule ignores allOSErrorerrors (not just access errors) — for example,_iterdir()wraps its scanner inexcept OSError: return.📚 Documentation preview 📚: https://cpython-previews--147996.org.readthedocs.build/