Skip to content

Fix StreamHasher hashing bytes rejected by the wrapped writer - #605

Open
Shubham-Padkonde wants to merge 1 commit into
dropbox:mainfrom
Shubham-Padkonde:fix/hash-successful-stream-writes
Open

Shubham-Padkonde wants to merge 1 commit into
dropbox:mainfrom
Shubham-Padkonde:fix/hash-successful-stream-writes

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown

StreamHasher.write currently hashes the full input before calling the wrapped writer. A short write therefore includes bytes that were never accepted, and a failed write changes the hash despite writing nothing.

Hash only the accepted prefix after write returns, preserving its return value. Zero-byte and non-blocking writes that return None leave the hash unchanged.

Added regressions for short, zero-byte, non-blocking, and failed writes. All four fail before the fix. All 104 unit tests pass on Python 3.13, and changed-file Ruff lint and formatting checks pass. No live Dropbox API calls were needed.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants