python / python/cpython

`hashlib.file_digest` does not honor current position for `io.BytesIO` inputs

Open
#155,419 1 comment 0 reactions 1 assignee View on GitHub

@picnixz is already working on this.

Since Aug 9, 2026.

stdlib type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

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.

cc @gpshead @hugovk

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs
  • gh-155422

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.