gh-146646: Document that glob functions suppress OSError#147996
gh-146646: Document that glob functions suppress OSError#147996vstinner merged 2 commits 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).
There was a problem hiding this comment.
Sure, let me do a quick update
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.
Thanks for suggesting, I will avoid force push |
…nGH-147996) (cherry picked from commit 8000a9de3c0b22f8202898a424c1008e13bd16ce) Co-authored-by: WYSIATI <chester.lee.cold@gmail.com>
|
GH-148288 is a backport of this pull request to the 3.14 branch. |
…nGH-147996) (cherry picked from commit 8000a9d) Co-authored-by: WYSIATI <chester.lee.cold@gmail.com>
|
GH-148289 is a backport of this pull request to the 3.13 branch. |
|
Merged, thanks. |
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/