Skip to content

Unify invalid-keyword error message across constructors - #184

Merged
ifduyue merged 2 commits into
masterfrom
fix/invalid-keyword-message
Aug 12, 2026
Merged

Unify invalid-keyword error message across constructors#184
ifduyue merged 2 commits into
masterfrom
fix/invalid-keyword-message

Conversation

@ifduyue

@ifduyue ifduyue commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Summary

Make constructor error messages consistent across interpreters. The vectorcall path (CPython) reported 'bad' is an invalid keyword argument for 'xxhash.xxh32()', but _parse_init_args (used by tp_init, e.g. PyPy) used a hardcoded '... for this function' message.

Changes

  • src/_xxhash.c: _parse_init_args now uses the same '%U' is an invalid keyword argument for '%s()' format and receives the qualified type name (e.g. xxhash.xxh32) instead of __init__()
  • This also fixes the multiple values for argument ... and takes at most 2 positional arguments messages on the tp_init path to name the type instead of __init__()
  • Bump version to 4.0.0.dev6

Testing

  • Verified both paths produce identical messages (xxh32(bad=1) and xxh32.__init__(h, bad=1))
  • Full test suite passes (132 tests)

_parse_init_args used a hardcoded 'this function' message, while the
vectorcall path reported the type name, so PyPy (which goes through
tp_init) showed a different error than CPython.  Use the same format and
pass the qualified type name (e.g. 'xxhash.xxh32') to _parse_init_args,
which also fixes 'multiple values' and 'too many positional' messages
on the tp_init path.
@codspeed-hq

codspeed-hq Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 148 untouched benchmarks
⏩ 66 skipped benchmarks1


Comparing fix/invalid-keyword-message (f01b08b) with master (51505c7)

Open in CodSpeed

Footnotes

  1. 66 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.

@ifduyue
ifduyue merged commit 8b83ba2 into master Aug 12, 2026
84 of 86 checks passed
@ifduyue
ifduyue deleted the fix/invalid-keyword-message branch August 12, 2026 15:59
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.

1 participant