gh-122179: Fix hashlib.file_digest and non-blocking I/O#122183
gh-122179: Fix hashlib.file_digest and non-blocking I/O#122183gpshead merged 6 commits intopython:mainfrom
Conversation
|
While this is technically an API change, I think this should be backported to releases that are still in bugfix mode, as the current behavior can cause hard to find bugs instead of failing fast. |
cmaloney
left a comment
There was a problem hiding this comment.
I think this is a positive change as is and test covers if this regresses in the future.
I think part of the cause of this is RawIO (ex. FileIO) vs. BufferedIO (and TextIO). Code exists in the wild using RawIO with this, which returns None, so updating to be more batteries included makes sense.
picnixz
left a comment
There was a problem hiding this comment.
I reviewed this last year, before I knew more about the workflow so here are some improved comments.
|
Sorry, @srittau and @gpshead, I could not cleanly backport this to |
| .. versionadded:: 3.11 | ||
|
|
||
| .. versionchanged:: next | ||
| Now raises a :exc:`BlockingIOError` if the file is opened in blocking |
There was a problem hiding this comment.
Was this meant to be "BlockingIOError if the file is not opened in blocking mode" or "BlockingIOError if the file is opened in non-blocking mode."?
As written it contradicts the previous addition 30 lines up and the NEWS.d entry.
There was a problem hiding this comment.
Should be "if the file is opened in non-blocking mode."
More specifically:
If .readinto returns None because it has no data and would block raises BlockingIOError.
(PR to update the docs welcome if you're interested in contributing directly; happy to help review)
hashlib.file_digest()can't handle non-blocking I/O #122179