Skip to content

Match hashlib constructor name type diagnostics - #9066

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix-hashlib-name-diagnostic
Oct 11, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix-hashlib-name-diagnostic

Conversation

@youknowdot

@youknowdot youknowdot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Current Python 3.15 main target

#8950 is merged. This PR now targets main and replays only its unique commits onto 06007c81fa99e813cbf4583dab326764ba0ef017. Current head: 4c8093dec7d9366dad4a81fe1abb77f41d621e06. The prior bootstrap commits are not part of this PR's diff.

Normal commit hooks, whitespace checks, and independent source/patch-equivalence review passed. The intervening main fixes are preserved and this PR introduces no changes under Lib/. No new local build or runtime validation is claimed for this rebased head. The maintainer-requested [skip ci] marker remains; full CI is intentionally paused pending selective validation.

Prior stack and validation history

The base/head references below describe earlier revisions; the current target and validation limits above supersede them.

Temporary CI pause

The head commit includes [skip ci] at the maintainer's request. This message-only amendment preserves the exact source tree and commit parents. Normal pull-request CI is intentionally skipped; required checks may remain pending. This does not itself cancel older runs or suppress pull_request_target workflows.

Python 3.15 stack

Depends on #8950 at 80d3e52f32341d3158c659d82a927373b51b6439. This PR targets the upstream stack/python-3.15-8950 branch at that exact commit, so its displayed diff contains only the leaf changes. Unique changes above #8950.

Current head e4f86457f3ae15def3a3d7b32cece1b73597b215 was checked by source/range-diff review, normal commit hooks, and patch checks. Its unique delta changes no files under Lib/ and inherits the 3.15.0 reference. No new local build or runtime execution is claimed for this stacked head; validation described below applies to the earlier head unless explicitly updated. Exact-head hosted CI is temporarily skipped.

Summary

Extract the Python 3.14-compatible _hashlib.new name-type diagnostic from #8954, correcting the mega implementation's formatting details.

For non-string names, report new() argument 'name' must be str, not TYPE. Match CPython's special spelling for None, stored native type name, and 50-byte UTF-8 precision without splitting a code point. Actual strings retain the existing PyUtf8StrRef conversion. Algorithm selection, hashing, and usedforsecurity behavior are unchanged; the separate 3.15 string= deprecation warning is excluded.

Sources: 3.14.7 generated parser, 3.14.8 bad-argument diagnostic, and UTF-8 precision handling.

Add six focused cases to the existing hashlib Python snippet, covering None, ordinary builtins, a qualified native type, and ASCII/non-ASCII truncation. No canonical assertions or unrelated diagnostic helpers change.

Validation

  • Independent source/ownership review, normal hooks, and native debug build passed.
  • Exact CPython 3.14.7/3.14.8 and native bounded checks agree on 12 type-name diagnostics and an accepted string subclass, including nested/renamed types, blocked Python metadata lookup, and UTF-8 boundaries. The baseline fails the new diagnostic regression.
  • The complete hashlib snippet and both snippet pytest entries pass using the pinned 3.14.7 reference.
  • Four unchanged canonical hashlib tests pass: unknown hashes, uppercase name normalization, name attributes, and Unicode-data rejection.
  • Stdlib and separately configured CAPI Clippy pass with -D warnings.

All behavior assertions are Python tests. Embedded-NUL handling and broader argument-binding diagnostic precedence are separate pre-existing contracts, not claims of this change. hosted CI is temporarily skipped.

Summary by CodeRabbit

  • New Features

    • RustPython now targets Python 3.15.
    • Sequence repetition for strings, bytes, and tuples is supported in both operand orders, including in-place multiplication.
  • Bug Fixes

    • _hashlib.new() now raises a TypeError for non-string algorithm names and identifies the supplied value’s type. Long type names are limited to 50 characters without splitting a UTF-8 character.
    • Improved compatibility for logarithms of large integer-like values, Windows timestamps, CSV dialect errors, struct formats, and other Python 3.15 behaviors.
    • Formatting errors now identify the argument and conversion specifier.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository: RustPython/RustPython/.coderabbit.yml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 137fce10-0db7-4173-9f73-8aca72d8838f

📥 Commits

Reviewing files that changed from the base of the PR and between 4a41ab5 and 586fc7d.


You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: RustPython/RustPython/.coderabbit.yml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 84bdd49c-e5bf-46a8-b8e1-f962ccf3bd14













📥 Commits

Reviewing files that changed from the base of the PR and between b63c3b0 and c2a9d84.














📒 Files selected for processing (2)
  • crates/stdlib/src/hashlib.rs
  • extra_tests/snippets/stdlib_hashlib.py













Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.















📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

_hashlib.new() now rejects non-string algorithm names with a TypeError that identifies the input type. Valid string names continue through the existing algorithm lookup.

Changes

Hashlib Name Validation

Layer / File(s) Summary
Validate and process algorithm names
crates/stdlib/src/hashlib.rs, extra_tests/snippets/stdlib_hashlib.py
HashName validates algorithm-name inputs and provides the string for lookup. Tests cover several non-string inputs and type names longer than 50 characters.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: youknowone
















































































Merge Risk: ⚪ Minimal · up to c2a9d

No identified issue blocks merging after normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the primary change: aligning hashlib constructor name type diagnostics with the reference behavior.





✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

















  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@youknowone
youknowone marked this pull request as ready for review October 10, 2026 12:58
@youknowone
youknowone enabled auto-merge (squash) October 10, 2026 12:58
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T16:12:09.092489Z 586fc7d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2a9d84ecf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

dict.into()
}

#[derive(Debug)]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add the required AI-assistance trailer

This commit is authored by Codex <codex@openai.com>, but the reviewed commit message has no Assisted-by: trailer. Repository policy requires that exact trailer form for every AI-assisted contribution, so add it before this commit is merged.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

):
with assert_raises(TypeError) as caught:
_hashlib.new(value)
assert str(caught.exception) == f"new() argument 'name' must be str, not {name}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove the prohibited test assertion

This appended loop introduces new test data, test logic, and an assertion in an existing test file. Repository policy explicitly forbids modifying test assertions, logic, or data, so remove this test hunk before merging.

AGENTS.md reference: AGENTS.md:L275-L275

Useful? React with 👍 / 👎.

@codspeed

codspeed Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing youknowdot:fix-hashlib-name-diagnostic (c2a9d84) with main (b63c3b0)

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

auto-merge was automatically disabled October 11, 2026 03:14

Head branch was pushed to by a user without write access

@youknowdot
youknowdot force-pushed the fix-hashlib-name-diagnostic branch from c2a9d84 to d7ddade Compare October 11, 2026 03:14
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@youknowdot
youknowdot force-pushed the fix-hashlib-name-diagnostic branch from d7ddade to e4f8645 Compare October 11, 2026 03:21
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@youknowone
youknowone changed the base branch from main to stack/python-3.15-8950 October 11, 2026 03:25
@youknowdot
youknowdot force-pushed the fix-hashlib-name-diagnostic branch from e4f8645 to 4c8093d Compare October 11, 2026 04:07
@youknowone
youknowone changed the base branch from stack/python-3.15-8950 to main October 11, 2026 04:09
@youknowdot
youknowdot force-pushed the fix-hashlib-name-diagnostic branch from 4c8093d to 4a41ab5 Compare October 11, 2026 04:14
@github-actions

Copy link
Copy Markdown
Contributor

📦 Library Dependencies

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

[ ] test: cpython/Lib/test/test_mmap.py (TODO: 19)

dependencies:

dependent tests: (2 tests)

  • mmap: test_os
    • multiprocessing.shared_memory: test_genericalias

Legend:

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

Use native type names, None spelling, and UTF-8 byte precision for invalid name arguments without changing accepted strings or hashing behavior.

Assisted-by: OpenAI Codex:model identifier unavailable
@youknowdot
youknowdot force-pushed the fix-hashlib-name-diagnostic branch from 4a41ab5 to 586fc7d Compare October 11, 2026 16:08
@youknowone
youknowone merged commit 924ef2f into RustPython:main Oct 11, 2026
20 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