From c49cfdc0751eb83fc87c8d2d74f6e5902e7416f8 Mon Sep 17 00:00:00 2001 From: Yue Du Date: Wed, 12 Aug 2026 06:33:58 +0000 Subject: [PATCH 1/2] Unify invalid-keyword error message across constructors _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. --- src/_xxhash.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/_xxhash.c b/src/_xxhash.c index 337fbb5..bfc4b0e 100644 --- a/src/_xxhash.c +++ b/src/_xxhash.c @@ -741,7 +741,8 @@ _parse_init_args(PyObject *args, PyObject *kwargs, PyUnicode_CompareWithASCIIString(key, "seed") == 0) continue; PyErr_Format(PyExc_TypeError, - "'%U' is an invalid keyword argument for this function", key); + "'%U' is an invalid keyword argument for '%s()'", + key, funcname); return -1; } } @@ -789,7 +790,7 @@ _parse_init_args(PyObject *args, PyObject *kwargs, } /* Macro to generate __init__ for each hash type. */ -#define XXHASH_INIT(type, reset_fn, update_fn, seed_cast) \ +#define XXHASH_INIT(type, name, reset_fn, update_fn, seed_cast) \ static int PY##type##_init(PY##type##Object *self, PyObject *args, \ PyObject *kwargs) \ { \ @@ -798,7 +799,7 @@ static int PY##type##_init(PY##type##Object *self, PyObject *args, \ Py_buffer buf = {NULL, NULL}; \ \ if (_parse_init_args(args, kwargs, &data_obj, &seed_val, \ - "__init__()") < 0) \ + name) < 0) \ return -1; \ \ if (data_obj) { \ @@ -818,7 +819,7 @@ static int PY##type##_init(PY##type##Object *self, PyObject *args, \ return 0; \ } -XXHASH_INIT(XXH32, XXH32_reset, XXH32_update, XXH32_hash_t) +XXHASH_INIT(XXH32, "xxhash.xxh32", XXH32_reset, XXH32_update, XXH32_hash_t) PyDoc_STRVAR( PYXXH32_update_doc, @@ -1169,7 +1170,7 @@ static PyObject *PYXXH64_new(PyTypeObject *type, PyObject *args, PyObject *kwarg return (PyObject *)self; } -XXHASH_INIT(XXH64, XXH64_reset, XXH64_update, XXH64_hash_t) +XXHASH_INIT(XXH64, "xxhash.xxh64", XXH64_reset, XXH64_update, XXH64_hash_t) PyDoc_STRVAR( PYXXH64_update_doc, @@ -1520,7 +1521,7 @@ static PyObject *PYXXH3_64_new(PyTypeObject *type, PyObject *args, PyObject *kwa return (PyObject *)self; } -XXHASH_INIT(XXH3_64, XXH3_64bits_reset_withSeed, XXH3_64bits_update, XXH64_hash_t) +XXHASH_INIT(XXH3_64, "xxhash.xxh3_64", XXH3_64bits_reset_withSeed, XXH3_64bits_update, XXH64_hash_t) PyDoc_STRVAR( PYXXH3_64_update_doc, @@ -1878,7 +1879,7 @@ static PyObject *PYXXH3_128_new(PyTypeObject *type, PyObject *args, PyObject *kw return (PyObject *)self; } -XXHASH_INIT(XXH3_128, XXH3_128bits_reset_withSeed, XXH3_128bits_update, XXH64_hash_t) +XXHASH_INIT(XXH3_128, "xxhash.xxh3_128", XXH3_128bits_reset_withSeed, XXH3_128bits_update, XXH64_hash_t) PyDoc_STRVAR( PYXXH3_128_update_doc, From f01b08b52da25020e40e115680a71762f7a0477a Mon Sep 17 00:00:00 2001 From: Yue Du Date: Wed, 12 Aug 2026 06:33:58 +0000 Subject: [PATCH 2/2] Bump version to 4.0.0.dev6 --- xxhash/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xxhash/version.py b/xxhash/version.py index ad975c9..795d903 100644 --- a/xxhash/version.py +++ b/xxhash/version.py @@ -1 +1 @@ -VERSION = "4.0.0.dev5" +VERSION = "4.0.0.dev6"