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
This commit is contained in:
Sebastian Rittau 2025-04-21 23:15:05 +02:00 committed by GitHub
parent fa70bf8593
commit 2b47f46d7d
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])