You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
hashlib.file_digest does not honor current position for io.BytesIO inputs #155419
hashlib.file_digest() takes a getbuffer() fast path that hashes the entire buffer regardless of tell(), so the same bytes at the same position give a different digest for io.BytesIO than for a real binary file.
We never had tests to exercise that behavior and we never got report about it. I want to sync the merges of all PRs at once so that the behavior is fixed simultaneously before the next release.
I decided to fix this instead of document the inconsistency because when not given a io.BytesIO object, we are actually honoring the position. So it's a bug.
Activity
Lib/hmac.pyandLib/hashlib.py#155413picnixz commentedon Aug 9, 2026
I decided to fix this instead of document the inconsistency because when not given a io.BytesIO object, we are actually honoring the position. So it's a bug.
pythongh-155419: honor the file object's current position in `hashlib
pythongh-155419: honor the file object's current position in `hashlib
pythongh-155419: honor the file object's current position in `hashlib