[3.13] gh-122179: Fix hashlib.file_digest and non-blocking I/O (GH-132787)

gh-122179: Fix hashlib.file_digest and non-blocking I/O (GH-122183)

* Fix hashlib.file_digest and non-blocking I/O
* Add documentation around this behavior
* Add versionchanged

(cherry picked from commit 2b47f46d7d)

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
This commit is contained in:
Gregory P. Smith 2025-04-21 14:55:57 -07:00 committed by GitHub
parent bb59fdec71
commit cdabbc126f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 22 additions and 1 deletions

View file

@ -231,6 +231,8 @@ def file_digest(fileobj, digest, /, *, _bufsize=2**18):
view = memoryview(buf)
while True:
size = fileobj.readinto(buf)
if size is None:
raise BlockingIOError("I/O operation would block.")
if size == 0:
break # EOF
digestobj.update(view[:size])