Title: `hashlib.file_digest()` can't handle non-blocking I/O · Issue #122179 · python/cpython · GitHub
Open Graph Title: `hashlib.file_digest()` can't handle non-blocking I/O · Issue #122179 · python/cpython
X Title: `hashlib.file_digest()` can't handle non-blocking I/O · Issue #122179 · python/cpython
Description: Bug report Bug description: This came up in python/typeshed#12414. The current implementation of file_digest() does not check the return value of fileobj.readinto() for None: cpython/Lib/hashlib.py Lines 232 to 236 in 2a5d1eb while True:...
Open Graph Description: Bug report Bug description: This came up in python/typeshed#12414. The current implementation of file_digest() does not check the return value of fileobj.readinto() for None: cpython/Lib/hashlib.py...
X Description: Bug report Bug description: This came up in python/typeshed#12414. The current implementation of file_digest() does not check the return value of fileobj.readinto() for None: cpython/Lib/hashlib.py...
Opengraph URL: https://github.com/python/cpython/issues/122179
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`hashlib.file_digest()` can't handle non-blocking I/O","articleBody":"# Bug report\n\n### Bug description:\n\nThis came up in python/typeshed#12414.\n\nThe current implementation of `file_digest()` does not check the return value of `fileobj.readinto()` for `None`:\n\nhttps://github.com/python/cpython/blob/2a5d1eb7073179a13159bce937afdbe240432e7d/Lib/hashlib.py#L232-L236\n\nWhile buffered file objects can't return `None`, unbuffered ones can when they are doing non-blocking I/O. Specifically, `file_digest()` [is documented](https://docs.python.org/3/library/hashlib.html#hashlib.file_digest) to take `SocketIO` objects, which can very much return `None`:\n\nhttps://github.com/python/cpython/blob/2a5d1eb7073179a13159bce937afdbe240432e7d/Lib/socket.py#L694-L714\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nOther\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-122183\n* gh-132787\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/srittau","@type":"Person","name":"srittau"},"datePublished":"2024-07-23T14:28:35Z","url":"https://github.com/python/cpython/issues/122179"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fa81046f-b37a-7332-c742-9ec7a09eee2b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C318:1CEB9:77619:A5E20:6B004F0B |
| html-safe-nonce | f30746e4edbd2226adeb895a4a0cc1f28a86b33e539d5d7f151a718b9a4b9dfb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMzE4OjFDRUI5Ojc3NjE5OkE1RTIwOjZCMDA0RjBCIiwidmlzaXRvcl9pZCI6Ijg3NjE0Nzk0NTMwNjc5ODg3NDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | bba6d86b72b5f45d444bba8c9d16aca4461a85fd05f0f558e7eb027456364760 |
| hovercard-subject-tag | issue:2425364066 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/python/cpython/122179/issue_layout |
| twitter:image | https://opengraph.githubassets.com/32e6b72be30e7b6e31c020ac15bc76da687008d6abd7c463662e6380db3c446c/python/cpython/issues/122179 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/32e6b72be30e7b6e31c020ac15bc76da687008d6abd7c463662e6380db3c446c/python/cpython/issues/122179 |
| og:image:alt | Bug report Bug description: This came up in python/typeshed#12414. The current implementation of file_digest() does not check the return value of fileobj.readinto() for None: cpython/Lib/hashlib.py... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | srittau |
| hostname | github.com |
| expected-hostname | github.com |
| None | f9517bf360d46638a1e5e7daee7158842fe5ef43c9000afa0e127564a7c2f39b |
| turbo-cache-control | no-preview |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b27c5dde30676028abd5c5fc53ce5c9b625f8281 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width