-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-122179: Fix hashlib.file_digest and non-blocking I/O #122183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
hashlib.file_digest()can't handle non-blocking I/O #122179