GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `hashlib.file_digest` does not honor current position for `io.BytesIO` inputs · Issue #155419 · python/cpython

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

New issue
Copy link
New issue
Copy link
Open
Open
hashlib.file_digest does not honor current position for io.BytesIO inputs#155419
Copy link
Assignees
picnixz
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@picnixz
picnixz
opened on Aug 9, 2026
Issue body actions

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-155419: honor the file object's current position in hashlib.file_digest #155422

Activity

  1. picnixz
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Aug 9, 2026
  2. picnixz
    added a parent issue on Aug 9, 2026
    • Meta-issue for bugs in Lib/hmac.py and Lib/hashlib.py #155413
  3. picnixz
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Aug 9, 2026
  4. picnixz
    self-assigned this
    on Aug 9, 2026
  5. picnixz commented on Aug 9, 2026

    @picnixz
    picnixz
    on Aug 9, 2026
    MemberAuthor
    More actions

    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.

    Reacted by Cody Maloney
  6. picnixz
    added 3 commits that reference this issue on Aug 9, 2026

    pythongh-155419: honor the file object's current position in `hashlib

    d81a4ff

    pythongh-155419: honor the file object's current position in `hashlib

    ac01ec2

    pythongh-155419: honor the file object's current position in `hashlib

    6817e92
  7. picnixz
    added 3 commits that reference this issue on Oct 23, 2026

    pythongh-155419: use the `hashlib.file_digest` fast path for `io.Byte…

    8b5acae

    pythongh-155419: test that importing `hashlib` does not import `io`

    644ac60

    pythongh-155419: test `hashlib.file_digest` on a non-`io.BytesIO` buffer

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

Metadata

Metadata

Assignees

  • @picnixz
    picnixz

Labels

stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.