Skip to content

_operator: Accept readable buffers in _compare_digest - #16211

Merged
JelleZijlstra merged 2 commits into
python:mainfrom
nightcityblade:fix-compare-digest-buffer
Aug 15, 2026
Merged

_operator: Accept readable buffers in _compare_digest#16211
JelleZijlstra merged 2 commits into
python:mainfrom
nightcityblade:fix-compare-digest-buffer

Conversation

@nightcityblade

Copy link
Copy Markdown
Contributor

Closes #15617

Accepts arbitrary readable buffer combinations in _operator._compare_digest, matching runtime behavior and _hashlib.compare_digest.

AI assistance: Codex was used to implement and verify this change.

@github-actions

This comment has been minimized.

Comment thread stdlib/_operator.pyi Outdated
@overload
def _compare_digest(a: ReadableBuffer, b: ReadableBuffer, /) -> bool: ...
@overload
def _compare_digest(a: AnyStr, b: AnyStr, /) -> bool: ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can now simplify the second overload to take str instead of AnyStr, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes — updated the second overload to use str and removed the now-unused AnyStr import in 61ec680. The targeted pre-commit, structure, Pyright, ty, pyrefly, mypy, and _operator stubtest checks all pass.

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JelleZijlstra
JelleZijlstra merged commit 5fb54bd into python:main Aug 15, 2026
88 checks passed
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.

_operator._compare_digest is incorrectly typed

2 participants