Skip to content

Include SHAKE algorithm names in HASHXOF repr#7132

Merged
youknowone merged 2 commits intoRustPython:mainfrom
moreal:fix/fail-hashlib-test_blocksize_name_sha3
Feb 15, 2026
Merged

Include SHAKE algorithm names in HASHXOF repr#7132
youknowone merged 2 commits intoRustPython:mainfrom
moreal:fix/fail-hashlib-test_blocksize_name_sha3

Conversation

@moreal
Copy link
Contributor

@moreal moreal commented Feb 14, 2026

Summary by CodeRabbit

  • Refactor
    • Enhanced string representation for XOF-style hash objects so their printed/viewed output consistently includes the object type and memory address, matching other hash objects and improving inspectability and logs.
  • Chores
    • Internal error-handling tightened for a key-length conversion path with no change to outward behavior.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 14, 2026

📝 Walkthrough

Walkthrough

PyHasherXof in crates/stdlib/src/hashlib.rs now includes Representable in its #[pyclass(...)] attribute and adds impl Representable for PyHasherXof with a custom repr_str. A minor error-handling expression in pbkdf2_hmac was compacted without behavior change.

Changes

Cohort / File(s) Summary
PyHasherXof Representable
crates/stdlib/src/hashlib.rs
Added with(Representable) to the #[pyclass(...)] for PyHasherXof and introduced impl Representable for PyHasherXof with repr_str returning "<{name} _hashlib.HASHXOF object @ {:#x}>".
pbkdf2_hmac error handling
crates/stdlib/src/hashlib.rs
Refactored lenusize conversion to a compact usize::try_from(len).map_err(...)? chain; semantics unchanged.

Sequence Diagram(s)

(none)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • youknowone

Poem

🐇
I patted bytes with a carroted grin,
Gave XOF a name and a neat hex pin,
Now traces show where the digests play,
A rabbit's nod for a tidy display 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (3 files):

⚔️ Lib/test/test_hashlib.py (content)
⚔️ Lib/test/test_struct.py (content)
⚔️ crates/stdlib/src/hashlib.rs (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding algorithm names (SHAKE) to the HASHXOF repr implementation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch fix/fail-hashlib-test_blocksize_name_sha3
  • Post resolved changes as copyable diffs in a comment

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@moreal moreal self-assigned this Feb 14, 2026
@moreal moreal marked this pull request as ready for review February 14, 2026 11:15
@moreal moreal force-pushed the fix/fail-hashlib-test_blocksize_name_sha3 branch from bbb8731 to 0629e37 Compare February 14, 2026 12:29
@moreal moreal force-pushed the fix/fail-hashlib-test_blocksize_name_sha3 branch from 0629e37 to ea47a77 Compare February 14, 2026 12:52
@github-actions
Copy link
Contributor

Code has been automatically formatted

The code in this PR has been formatted using:

  • cargo fmt --all
    Please pull the latest changes before pushing again:
git pull origin fix/fail-hashlib-test_blocksize_name_sha3

@github-actions
Copy link
Contributor

📦 Library Dependencies

The following Lib/ modules were modified. Here are their dependencies:

[x] lib: cpython/Lib/hashlib.py
[x] test: cpython/Lib/test/test_hashlib.py (TODO: 7)

dependencies:

  • hashlib

dependent tests: (15 tests)

  • hashlib: test_hashlib test_hmac test_smtplib test_tarfile test_unicodedata test_urllib2_localnet
    • urllib.request: test_http_cookiejar test_pathlib test_pydoc test_site test_ssl test_urllib test_urllib2 test_urllib2net test_urllibnet

Legend:

  • [+] path exists in CPython
  • [x] up-to-date, [ ] outdated

@youknowone youknowone merged commit cf21e2d into RustPython:main Feb 15, 2026
14 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.

2 participants