Title: GH-90208: Suppress OSError exceptions from `pathlib.Path.glob()` by barneygale · Pull Request #104141 · python/cpython · GitHub
Open Graph Title: GH-90208: Suppress OSError exceptions from `pathlib.Path.glob()` by barneygale · Pull Request #104141 · python/cpython
X Title: GH-90208: Suppress OSError exceptions from `pathlib.Path.glob()` by barneygale · Pull Request #104141 · python/cpython
Description: pathlib.Path.glob() now suppresses all OSError exceptions, except those raised from calling is_dir() on the top-level path. Previously, glob() suppressed ENOENT, ENOTDIR, EBADF and ELOOP errors and their Windows equivalents. PermissionError was also suppressed unless it occurred when calling is_dir() on the top-level path. However, the selector would abort prematurely if a PermissionError was raised, and so glob() could return incomplete results. Rationale Globbing is a shell feature, per the glob module docs: The glob module finds all the pathnames matching a specified pattern according to the rules used by the Unix shell When implemented by shells, globbing matches as much as possible without aborting. In fact, other Python functions that walk a directory tree usually suppress errors, e.g.: glob.glob() os.walk() and os.fwalk() (configurable) pathlib.Path.walk() (configurable) The rationale is the same: an error from one file/directory isn't fatal for the walk, and we can continue walking elsewhere. Finally, as noted above, pathlib.Path.glob() already ignores the most common kinds of OSError. This shows some recognition of the above rationale, though incomplete. Issue: gh-90208
Open Graph Description: pathlib.Path.glob() now suppresses all OSError exceptions, except those raised from calling is_dir() on the top-level path. Previously, glob() suppressed ENOENT, ENOTDIR, EBADF and ELOOP errors and...
X Description: pathlib.Path.glob() now suppresses all OSError exceptions, except those raised from calling is_dir() on the top-level path. Previously, glob() suppressed ENOENT, ENOTDIR, EBADF and ELOOP errors and...
Opengraph URL: https://github.com/python/cpython/pull/104141
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:d6b26527-e24a-3f21-99cc-7cf4f5471a8a |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | B40E:27157C:193A969:21CB187:6969B1BC |
| html-safe-nonce | 741fc9b568345aa2852a649d3947262e3b4bb7be588ac15efacdff985b73111c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDBFOjI3MTU3QzoxOTNBOTY5OjIxQ0IxODc6Njk2OUIxQkMiLCJ2aXNpdG9yX2lkIjoiNjc2MzIyNzE3OTYzNTAyODQxMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 984dc8539d3d3bdb493c6d67fc2ea0e4a03e6aa920b4000b8d6f193c9f17f70d |
| hovercard-subject-tag | pull_request:1337160120 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/pull/104141/files |
| twitter:image | https://avatars.githubusercontent.com/u/960340?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/960340?s=400&v=4 |
| og:image:alt | pathlib.Path.glob() now suppresses all OSError exceptions, except those raised from calling is_dir() on the top-level path. Previously, glob() suppressed ENOENT, ENOTDIR, EBADF and ELOOP errors and... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b23b8fcc855cd29bb04d6c94aafa62d336bf44eefa8229444eecc968cad03aee |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0672399d88424758731ec07fe24509e23bb17fb5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width