diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index 8c9fa81f0036cc..e090cbdc8f91fd 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -8,6 +8,7 @@ from binascii import unhexlify import hashlib import importlib +import inspect import io import itertools import logging @@ -316,6 +317,18 @@ def test_clinic_signature(self): DEPRECATED_STRING_PARAMETER): self._hashlib.new(digest_name, string=b'') + def test_clinic_signature_apply_defaults(self): + # gh-162714: the defaults of the signature form a valid call + for constructor in self.hash_constructors: + try: + signature = inspect.signature(constructor) + except ValueError: # built-in SHA-3 types have no signature + continue + with self.subTest(constructor.__name__): + bound = signature.bind(b'') + bound.apply_defaults() + constructor(*bound.args, **bound.kwargs) + @unittest.skipIf(get_fips_mode(), "skip in FIPS mode") def test_clinic_signature_errors(self): nomsg = b'' @@ -354,6 +367,7 @@ def test_clinic_signature_errors(self): [(nomsg,), dict(string=nomsg), conflicting_call], [(mymsg,), dict(string=nomsg), conflicting_call], [(), dict(data=nomsg, string=nomsg), conflicting_call], + [(nomsg,), dict(string=None), conflicting_call], ]: for constructor in self.hash_constructors: digest_name = constructor(b'').name diff --git a/Misc/NEWS.d/next/Library/2026-12-02-12-00-00.gh-issue-162714.Hq7sZp.rst b/Misc/NEWS.d/next/Library/2026-12-02-12-00-00.gh-issue-162714.Hq7sZp.rst new file mode 100644 index 00000000000000..4f337817f6ce99 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-12-02-12-00-00.gh-issue-162714.Hq7sZp.rst @@ -0,0 +1,4 @@ +:mod:`hashlib`: the deprecated *string* keyword parameter of hash object +constructors is no longer part of their signature, so that calls built with +:meth:`inspect.BoundArguments.apply_defaults` are valid. +Patch by Bénédikt Tran. diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c index 1088685d37b4d1..5639e471e74746 100644 --- a/Modules/_hashopenssl.c +++ b/Modules/_hashopenssl.c @@ -1342,6 +1342,7 @@ _hashlib_HASH(_hashlibstate *state, const char *digestname, PyObject *data_obj, /* The module-level function: new() */ /*[clinic input] +@text_signature "($module, /, name, data=b'', *, usedforsecurity=True)" _hashlib.new as _hashlib_HASH_new name: str @@ -1361,7 +1362,7 @@ The MD5 and SHA1 algorithms are always supported. static PyObject * _hashlib_HASH_new_impl(PyObject *module, const char *name, PyObject *data, int usedforsecurity, PyObject *string) -/*[clinic end generated code: output=b905aaf9840c1bbd input=c34af6c6e696d44e]*/ +/*[clinic end generated code: output=b905aaf9840c1bbd input=8f9d08a66387e4d8]*/ { PyObject *data_obj; if (_Py_hashlib_data_argument(&data_obj, data, string) < 0) { @@ -1373,6 +1374,7 @@ _hashlib_HASH_new_impl(PyObject *module, const char *name, PyObject *data, /*[clinic input] +@text_signature "($module, /, data=b'', *, usedforsecurity=True)" _hashlib.openssl_md5 data: object(c_default="NULL") = b'' @@ -1387,13 +1389,14 @@ Returns a md5 hash object; optionally initialized with a string static PyObject * _hashlib_openssl_md5_impl(PyObject *module, PyObject *data, int usedforsecurity, PyObject *string) -/*[clinic end generated code: output=ca8cf184d90f7432 input=e7c0adbd6a867db1]*/ +/*[clinic end generated code: output=ca8cf184d90f7432 input=1242105b6a5176d6]*/ { CALL_HASHLIB_NEW(module, Py_hash_md5, data, string, usedforsecurity); } /*[clinic input] +@text_signature "($module, /, data=b'', *, usedforsecurity=True)" _hashlib.openssl_sha1 data: object(c_default="NULL") = b'' @@ -1408,13 +1411,14 @@ Returns a sha1 hash object; optionally initialized with a string static PyObject * _hashlib_openssl_sha1_impl(PyObject *module, PyObject *data, int usedforsecurity, PyObject *string) -/*[clinic end generated code: output=1736fb7b310d64be input=f7e5bb1711e952d8]*/ +/*[clinic end generated code: output=1736fb7b310d64be input=eca1e1e061f67ba8]*/ { CALL_HASHLIB_NEW(module, Py_hash_sha1, data, string, usedforsecurity); } /*[clinic input] +@text_signature "($module, /, data=b'', *, usedforsecurity=True)" _hashlib.openssl_sha224 data: object(c_default="NULL") = b'' @@ -1429,13 +1433,14 @@ Returns a sha224 hash object; optionally initialized with a string static PyObject * _hashlib_openssl_sha224_impl(PyObject *module, PyObject *data, int usedforsecurity, PyObject *string) -/*[clinic end generated code: output=0d6ff57be5e5c140 input=3820fff7ed3a53b8]*/ +/*[clinic end generated code: output=0d6ff57be5e5c140 input=c6bb80a6e9b8e982]*/ { CALL_HASHLIB_NEW(module, Py_hash_sha224, data, string, usedforsecurity); } /*[clinic input] +@text_signature "($module, /, data=b'', *, usedforsecurity=True)" _hashlib.openssl_sha256 data: object(c_default="NULL") = b'' @@ -1450,13 +1455,14 @@ Returns a sha256 hash object; optionally initialized with a string static PyObject * _hashlib_openssl_sha256_impl(PyObject *module, PyObject *data, int usedforsecurity, PyObject *string) -/*[clinic end generated code: output=412ea7111555b6e7 input=9a2f115cf1f7e0eb]*/ +/*[clinic end generated code: output=412ea7111555b6e7 input=2f0e3f6ed9e05e89]*/ { CALL_HASHLIB_NEW(module, Py_hash_sha256, data, string, usedforsecurity); } /*[clinic input] +@text_signature "($module, /, data=b'', *, usedforsecurity=True)" _hashlib.openssl_sha384 data: object(c_default="NULL") = b'' @@ -1471,13 +1477,14 @@ Returns a sha384 hash object; optionally initialized with a string static PyObject * _hashlib_openssl_sha384_impl(PyObject *module, PyObject *data, int usedforsecurity, PyObject *string) -/*[clinic end generated code: output=2e0dc395b59ed726 input=1ea48f6f01e77cfb]*/ +/*[clinic end generated code: output=2e0dc395b59ed726 input=5691ef74159f0bbc]*/ { CALL_HASHLIB_NEW(module, Py_hash_sha384, data, string, usedforsecurity); } /*[clinic input] +@text_signature "($module, /, data=b'', *, usedforsecurity=True)" _hashlib.openssl_sha512 data: object(c_default="NULL") = b'' @@ -1492,7 +1499,7 @@ Returns a sha512 hash object; optionally initialized with a string static PyObject * _hashlib_openssl_sha512_impl(PyObject *module, PyObject *data, int usedforsecurity, PyObject *string) -/*[clinic end generated code: output=4bdd760388dbfc0f input=3cf56903e07d1f5c]*/ +/*[clinic end generated code: output=4bdd760388dbfc0f input=0b97ed23dc54ab56]*/ { CALL_HASHLIB_NEW(module, Py_hash_sha512, data, string, usedforsecurity); } @@ -1501,6 +1508,7 @@ _hashlib_openssl_sha512_impl(PyObject *module, PyObject *data, #ifdef PY_OPENSSL_HAS_SHA3 /*[clinic input] +@text_signature "($module, /, data=b'', *, usedforsecurity=True)" _hashlib.openssl_sha3_224 data: object(c_default="NULL") = b'' @@ -1515,12 +1523,13 @@ Returns a sha3-224 hash object; optionally initialized with a string static PyObject * _hashlib_openssl_sha3_224_impl(PyObject *module, PyObject *data, int usedforsecurity, PyObject *string) -/*[clinic end generated code: output=6d8dc2a924f3ba35 input=7f14f16a9f6a3158]*/ +/*[clinic end generated code: output=6d8dc2a924f3ba35 input=7107e36646dc3a8e]*/ { CALL_HASHLIB_NEW(module, Py_hash_sha3_224, data, string, usedforsecurity); } /*[clinic input] +@text_signature "($module, /, data=b'', *, usedforsecurity=True)" _hashlib.openssl_sha3_256 data: object(c_default="NULL") = b'' @@ -1535,12 +1544,13 @@ Returns a sha3-256 hash object; optionally initialized with a string static PyObject * _hashlib_openssl_sha3_256_impl(PyObject *module, PyObject *data, int usedforsecurity, PyObject *string) -/*[clinic end generated code: output=9e520f537b3a4622 input=7987150939d5e352]*/ +/*[clinic end generated code: output=9e520f537b3a4622 input=a0de473419ff4593]*/ { CALL_HASHLIB_NEW(module, Py_hash_sha3_256, data, string, usedforsecurity); } /*[clinic input] +@text_signature "($module, /, data=b'', *, usedforsecurity=True)" _hashlib.openssl_sha3_384 data: object(c_default="NULL") = b'' @@ -1555,12 +1565,13 @@ Returns a sha3-384 hash object; optionally initialized with a string static PyObject * _hashlib_openssl_sha3_384_impl(PyObject *module, PyObject *data, int usedforsecurity, PyObject *string) -/*[clinic end generated code: output=d239ba0463fd6138 input=fc943401f67e3b81]*/ +/*[clinic end generated code: output=d239ba0463fd6138 input=1c9c36f4b0fb859e]*/ { CALL_HASHLIB_NEW(module, Py_hash_sha3_384, data, string, usedforsecurity); } /*[clinic input] +@text_signature "($module, /, data=b'', *, usedforsecurity=True)" _hashlib.openssl_sha3_512 data: object(c_default="NULL") = b'' @@ -1575,7 +1586,7 @@ Returns a sha3-512 hash object; optionally initialized with a string static PyObject * _hashlib_openssl_sha3_512_impl(PyObject *module, PyObject *data, int usedforsecurity, PyObject *string) -/*[clinic end generated code: output=17662f21038c2278 input=6601ddd2c6c1516d]*/ +/*[clinic end generated code: output=17662f21038c2278 input=eb09a63a3d478630]*/ { CALL_HASHLIB_NEW(module, Py_hash_sha3_512, data, string, usedforsecurity); } @@ -1584,6 +1595,7 @@ _hashlib_openssl_sha3_512_impl(PyObject *module, PyObject *data, #ifdef PY_OPENSSL_HAS_SHAKE /*[clinic input] @permit_long_summary +@text_signature "($module, /, data=b'', *, usedforsecurity=True)" _hashlib.openssl_shake_128 data: object(c_default="NULL") = b'' @@ -1598,13 +1610,14 @@ Returns a shake-128 variable hash object; optionally initialized with a string static PyObject * _hashlib_openssl_shake_128_impl(PyObject *module, PyObject *data, int usedforsecurity, PyObject *string) -/*[clinic end generated code: output=4e6afed8d18980ad input=0d2803af1158b23c]*/ +/*[clinic end generated code: output=4e6afed8d18980ad input=ef04b0f787e1f5f0]*/ { CALL_HASHLIB_NEW(module, Py_hash_shake_128, data, string, usedforsecurity); } /*[clinic input] @permit_long_summary +@text_signature "($module, /, data=b'', *, usedforsecurity=True)" _hashlib.openssl_shake_256 data: object(c_default="NULL") = b'' @@ -1619,7 +1632,7 @@ Returns a shake-256 variable hash object; optionally initialized with a string static PyObject * _hashlib_openssl_shake_256_impl(PyObject *module, PyObject *data, int usedforsecurity, PyObject *string) -/*[clinic end generated code: output=62481bce4a77d16c input=f27b98d9c749f55d]*/ +/*[clinic end generated code: output=62481bce4a77d16c input=38a2429ec6143f98]*/ { CALL_HASHLIB_NEW(module, Py_hash_shake_256, data, string, usedforsecurity); } diff --git a/Modules/blake2module.c b/Modules/blake2module.c index 5ea64cb28885db..f483e71af7be09 100644 --- a/Modules/blake2module.c +++ b/Modules/blake2module.c @@ -666,6 +666,7 @@ py_blake2_new(PyTypeObject *type, PyObject *data, int digest_size, /*[clinic input] @classmethod +@text_signature "(data=b'', *, digest_size=_blake2.blake2b.MAX_DIGEST_SIZE, key=b'', salt=b'', person=b'', fanout=1, depth=1, leaf_size=0, node_offset=0, node_depth=0, inner_size=0, last_node=False, usedforsecurity=True)" _blake2.blake2b.__new__ as py_blake2b_new data as data_obj: object(c_default="NULL") = b'' * @@ -693,7 +694,7 @@ py_blake2b_new_impl(PyTypeObject *type, PyObject *data_obj, int digest_size, unsigned long long node_offset, int node_depth, int inner_size, int last_node, int usedforsecurity, PyObject *string) -/*[clinic end generated code: output=de64bd850606b6a0 input=32832fb37d13c03d]*/ +/*[clinic end generated code: output=de64bd850606b6a0 input=3910410fa9a13dea]*/ { PyObject *data; if (_Py_hashlib_data_argument(&data, data_obj, string) < 0) { @@ -706,6 +707,7 @@ py_blake2b_new_impl(PyTypeObject *type, PyObject *data_obj, int digest_size, /*[clinic input] @classmethod +@text_signature "(data=b'', *, digest_size=_blake2.blake2s.MAX_DIGEST_SIZE, key=b'', salt=b'', person=b'', fanout=1, depth=1, leaf_size=0, node_offset=0, node_depth=0, inner_size=0, last_node=False, usedforsecurity=True)" _blake2.blake2s.__new__ as py_blake2s_new data as data_obj: object(c_default="NULL") = b'' * @@ -733,7 +735,7 @@ py_blake2s_new_impl(PyTypeObject *type, PyObject *data_obj, int digest_size, unsigned long long node_offset, int node_depth, int inner_size, int last_node, int usedforsecurity, PyObject *string) -/*[clinic end generated code: output=582a0c4295cc3a3c input=da467fc9dae646bb]*/ +/*[clinic end generated code: output=582a0c4295cc3a3c input=a95acd771b2aa71f]*/ { PyObject *data; if (_Py_hashlib_data_argument(&data, data_obj, string) < 0) { diff --git a/Modules/clinic/_hashopenssl.c.h b/Modules/clinic/_hashopenssl.c.h index 17ed37bbd3b619..6adcb95f5fab7d 100644 --- a/Modules/clinic/_hashopenssl.c.h +++ b/Modules/clinic/_hashopenssl.c.h @@ -243,7 +243,7 @@ _hashlib_HASHXOF_hexdigest(PyObject *self, PyObject *const *args, Py_ssize_t nar #endif /* defined(PY_OPENSSL_HAS_SHAKE) */ PyDoc_STRVAR(_hashlib_HASH_new__doc__, -"new($module, /, name, data=b\'\', *, usedforsecurity=True, string=None)\n" +"new($module, /, name, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Return a new hash object using the named algorithm.\n" @@ -347,7 +347,7 @@ _hashlib_HASH_new(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyO } PyDoc_STRVAR(_hashlib_openssl_md5__doc__, -"openssl_md5($module, /, data=b\'\', *, usedforsecurity=True, string=None)\n" +"openssl_md5($module, /, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Returns a md5 hash object; optionally initialized with a string"); @@ -432,7 +432,7 @@ _hashlib_openssl_md5(PyObject *module, PyObject *const *args, Py_ssize_t nargs, } PyDoc_STRVAR(_hashlib_openssl_sha1__doc__, -"openssl_sha1($module, /, data=b\'\', *, usedforsecurity=True, string=None)\n" +"openssl_sha1($module, /, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Returns a sha1 hash object; optionally initialized with a string"); @@ -517,8 +517,7 @@ _hashlib_openssl_sha1(PyObject *module, PyObject *const *args, Py_ssize_t nargs, } PyDoc_STRVAR(_hashlib_openssl_sha224__doc__, -"openssl_sha224($module, /, data=b\'\', *, usedforsecurity=True,\n" -" string=None)\n" +"openssl_sha224($module, /, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Returns a sha224 hash object; optionally initialized with a string"); @@ -603,8 +602,7 @@ _hashlib_openssl_sha224(PyObject *module, PyObject *const *args, Py_ssize_t narg } PyDoc_STRVAR(_hashlib_openssl_sha256__doc__, -"openssl_sha256($module, /, data=b\'\', *, usedforsecurity=True,\n" -" string=None)\n" +"openssl_sha256($module, /, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Returns a sha256 hash object; optionally initialized with a string"); @@ -689,8 +687,7 @@ _hashlib_openssl_sha256(PyObject *module, PyObject *const *args, Py_ssize_t narg } PyDoc_STRVAR(_hashlib_openssl_sha384__doc__, -"openssl_sha384($module, /, data=b\'\', *, usedforsecurity=True,\n" -" string=None)\n" +"openssl_sha384($module, /, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Returns a sha384 hash object; optionally initialized with a string"); @@ -775,8 +772,7 @@ _hashlib_openssl_sha384(PyObject *module, PyObject *const *args, Py_ssize_t narg } PyDoc_STRVAR(_hashlib_openssl_sha512__doc__, -"openssl_sha512($module, /, data=b\'\', *, usedforsecurity=True,\n" -" string=None)\n" +"openssl_sha512($module, /, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Returns a sha512 hash object; optionally initialized with a string"); @@ -863,8 +859,7 @@ _hashlib_openssl_sha512(PyObject *module, PyObject *const *args, Py_ssize_t narg #if defined(PY_OPENSSL_HAS_SHA3) PyDoc_STRVAR(_hashlib_openssl_sha3_224__doc__, -"openssl_sha3_224($module, /, data=b\'\', *, usedforsecurity=True,\n" -" string=None)\n" +"openssl_sha3_224($module, /, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Returns a sha3-224 hash object; optionally initialized with a string"); @@ -953,8 +948,7 @@ _hashlib_openssl_sha3_224(PyObject *module, PyObject *const *args, Py_ssize_t na #if defined(PY_OPENSSL_HAS_SHA3) PyDoc_STRVAR(_hashlib_openssl_sha3_256__doc__, -"openssl_sha3_256($module, /, data=b\'\', *, usedforsecurity=True,\n" -" string=None)\n" +"openssl_sha3_256($module, /, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Returns a sha3-256 hash object; optionally initialized with a string"); @@ -1043,8 +1037,7 @@ _hashlib_openssl_sha3_256(PyObject *module, PyObject *const *args, Py_ssize_t na #if defined(PY_OPENSSL_HAS_SHA3) PyDoc_STRVAR(_hashlib_openssl_sha3_384__doc__, -"openssl_sha3_384($module, /, data=b\'\', *, usedforsecurity=True,\n" -" string=None)\n" +"openssl_sha3_384($module, /, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Returns a sha3-384 hash object; optionally initialized with a string"); @@ -1133,8 +1126,7 @@ _hashlib_openssl_sha3_384(PyObject *module, PyObject *const *args, Py_ssize_t na #if defined(PY_OPENSSL_HAS_SHA3) PyDoc_STRVAR(_hashlib_openssl_sha3_512__doc__, -"openssl_sha3_512($module, /, data=b\'\', *, usedforsecurity=True,\n" -" string=None)\n" +"openssl_sha3_512($module, /, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Returns a sha3-512 hash object; optionally initialized with a string"); @@ -1223,8 +1215,7 @@ _hashlib_openssl_sha3_512(PyObject *module, PyObject *const *args, Py_ssize_t na #if defined(PY_OPENSSL_HAS_SHAKE) PyDoc_STRVAR(_hashlib_openssl_shake_128__doc__, -"openssl_shake_128($module, /, data=b\'\', *, usedforsecurity=True,\n" -" string=None)\n" +"openssl_shake_128($module, /, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Returns a shake-128 variable hash object; optionally initialized with a string"); @@ -1313,8 +1304,7 @@ _hashlib_openssl_shake_128(PyObject *module, PyObject *const *args, Py_ssize_t n #if defined(PY_OPENSSL_HAS_SHAKE) PyDoc_STRVAR(_hashlib_openssl_shake_256__doc__, -"openssl_shake_256($module, /, data=b\'\', *, usedforsecurity=True,\n" -" string=None)\n" +"openssl_shake_256($module, /, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Returns a shake-256 variable hash object; optionally initialized with a string"); @@ -1986,4 +1976,4 @@ _hashlib_compare_digest(PyObject *module, PyObject *const *args, Py_ssize_t narg #ifndef _HASHLIB_OPENSSL_SHAKE_256_METHODDEF #define _HASHLIB_OPENSSL_SHAKE_256_METHODDEF #endif /* !defined(_HASHLIB_OPENSSL_SHAKE_256_METHODDEF) */ -/*[clinic end generated code: output=cf405e652a340bb2 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=678f7f3dbfde110f input=a9049054013a1b77]*/ diff --git a/Modules/clinic/blake2module.c.h b/Modules/clinic/blake2module.c.h index dc70abfaf05543..fdb84387855a1f 100644 --- a/Modules/clinic/blake2module.c.h +++ b/Modules/clinic/blake2module.c.h @@ -10,10 +10,7 @@ preserve #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() PyDoc_STRVAR(py_blake2b_new__doc__, -"blake2b(data=b\'\', *, digest_size=_blake2.blake2b.MAX_DIGEST_SIZE,\n" -" key=b\'\', salt=b\'\', person=b\'\', fanout=1, depth=1, leaf_size=0,\n" -" node_offset=0, node_depth=0, inner_size=0, last_node=False,\n" -" usedforsecurity=True, string=None)\n" +"blake2b(data=b\'\', *, digest_size=_blake2.blake2b.MAX_DIGEST_SIZE, key=b\'\', salt=b\'\', person=b\'\', fanout=1, depth=1, leaf_size=0, node_offset=0, node_depth=0, inner_size=0, last_node=False, usedforsecurity=True)\n" "--\n" "\n" "Return a new BLAKE2b hash object."); @@ -219,10 +216,7 @@ py_blake2b_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } PyDoc_STRVAR(py_blake2s_new__doc__, -"blake2s(data=b\'\', *, digest_size=_blake2.blake2s.MAX_DIGEST_SIZE,\n" -" key=b\'\', salt=b\'\', person=b\'\', fanout=1, depth=1, leaf_size=0,\n" -" node_offset=0, node_depth=0, inner_size=0, last_node=False,\n" -" usedforsecurity=True, string=None)\n" +"blake2s(data=b\'\', *, digest_size=_blake2.blake2s.MAX_DIGEST_SIZE, key=b\'\', salt=b\'\', person=b\'\', fanout=1, depth=1, leaf_size=0, node_offset=0, node_depth=0, inner_size=0, last_node=False, usedforsecurity=True)\n" "--\n" "\n" "Return a new BLAKE2s hash object."); @@ -506,4 +500,4 @@ _blake2_blake2b_hexdigest(PyObject *self, PyObject *Py_UNUSED(ignored)) { return _blake2_blake2b_hexdigest_impl((Blake2Object *)self); } -/*[clinic end generated code: output=5f76c18211cd7f8f input=a9049054013a1b77]*/ +/*[clinic end generated code: output=c4394f9256e774ab input=a9049054013a1b77]*/ diff --git a/Modules/clinic/md5module.c.h b/Modules/clinic/md5module.c.h index f76902586dddb2..665578bea12bd4 100644 --- a/Modules/clinic/md5module.c.h +++ b/Modules/clinic/md5module.c.h @@ -89,7 +89,7 @@ MD5Type_update(PyObject *self, PyObject *obj) } PyDoc_STRVAR(_md5_md5__doc__, -"md5($module, /, data=b\'\', *, usedforsecurity=True, string=None)\n" +"md5($module, /, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Return a new MD5 hash object; optionally initialized with a string."); @@ -172,4 +172,4 @@ _md5_md5(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw exit: return return_value; } -/*[clinic end generated code: output=920fe54b9ed06f92 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=8364a8d59826a5e3 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/sha1module.c.h b/Modules/clinic/sha1module.c.h index 4a58d0cd9b82a4..ec66d0339c128c 100644 --- a/Modules/clinic/sha1module.c.h +++ b/Modules/clinic/sha1module.c.h @@ -89,7 +89,7 @@ SHA1Type_update(PyObject *self, PyObject *obj) } PyDoc_STRVAR(_sha1_sha1__doc__, -"sha1($module, /, data=b\'\', *, usedforsecurity=True, string=None)\n" +"sha1($module, /, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Return a new SHA1 hash object; optionally initialized with a string."); @@ -172,4 +172,4 @@ _sha1_sha1(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * exit: return return_value; } -/*[clinic end generated code: output=fd5a917404b68c4f input=a9049054013a1b77]*/ +/*[clinic end generated code: output=12f934c02d2edf31 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/sha2module.c.h b/Modules/clinic/sha2module.c.h index 07be91e4f6c68f..1fb90af5fa6c17 100644 --- a/Modules/clinic/sha2module.c.h +++ b/Modules/clinic/sha2module.c.h @@ -169,7 +169,7 @@ SHA512Type_update(PyObject *self, PyObject *obj) } PyDoc_STRVAR(_sha2_sha256__doc__, -"sha256($module, /, data=b\'\', *, usedforsecurity=True, string=None)\n" +"sha256($module, /, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Return a new SHA-256 hash object; optionally initialized with a string."); @@ -254,7 +254,7 @@ _sha2_sha256(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject } PyDoc_STRVAR(_sha2_sha224__doc__, -"sha224($module, /, data=b\'\', *, usedforsecurity=True, string=None)\n" +"sha224($module, /, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Return a new SHA-224 hash object; optionally initialized with a string."); @@ -339,7 +339,7 @@ _sha2_sha224(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject } PyDoc_STRVAR(_sha2_sha512__doc__, -"sha512($module, /, data=b\'\', *, usedforsecurity=True, string=None)\n" +"sha512($module, /, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Return a new SHA-512 hash object; optionally initialized with a string."); @@ -424,7 +424,7 @@ _sha2_sha512(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject } PyDoc_STRVAR(_sha2_sha384__doc__, -"sha384($module, /, data=b\'\', *, usedforsecurity=True, string=None)\n" +"sha384($module, /, data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Return a new SHA-384 hash object; optionally initialized with a string."); @@ -507,4 +507,4 @@ _sha2_sha384(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject exit: return return_value; } -/*[clinic end generated code: output=90625b237c774a9f input=a9049054013a1b77]*/ +/*[clinic end generated code: output=f0391f6e473774d2 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/sha3module.c.h b/Modules/clinic/sha3module.c.h index 7fdc707626c324..37b70001e442d4 100644 --- a/Modules/clinic/sha3module.c.h +++ b/Modules/clinic/sha3module.c.h @@ -10,7 +10,7 @@ preserve #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() PyDoc_STRVAR(py_sha3_new__doc__, -"sha3_224(data=b\'\', *, usedforsecurity=True, string=None)\n" +"sha3_224(data=b\'\', *, usedforsecurity=True)\n" "--\n" "\n" "Return a new SHA3 hash object."); @@ -320,4 +320,4 @@ _sha3_shake_128_hexdigest(PyObject *self, PyObject *const *args, Py_ssize_t narg exit: return return_value; } -/*[clinic end generated code: output=78284adde71d590c input=a9049054013a1b77]*/ +/*[clinic end generated code: output=bec89a636dccb41a input=a9049054013a1b77]*/ diff --git a/Modules/md5module.c b/Modules/md5module.c index 537fbc096b3112..7f127f991e3320 100644 --- a/Modules/md5module.c +++ b/Modules/md5module.c @@ -259,6 +259,7 @@ static PyType_Spec md5_type_spec = { /* The single module-level function: new() */ /*[clinic input] +@text_signature "($module, /, data=b'', *, usedforsecurity=True)" _md5.md5 data: object(c_default="NULL") = b'' @@ -272,7 +273,7 @@ Return a new MD5 hash object; optionally initialized with a string. static PyObject * _md5_md5_impl(PyObject *module, PyObject *data, int usedforsecurity, PyObject *string_obj) -/*[clinic end generated code: output=d45e187d3d16f3a8 input=7ea5c5366dbb44bf]*/ +/*[clinic end generated code: output=d45e187d3d16f3a8 input=8972c77b57ff5eda]*/ { PyObject *string; if (_Py_hashlib_data_argument(&string, data, string_obj) < 0) { diff --git a/Modules/sha1module.c b/Modules/sha1module.c index 28fb73605f3f51..9ddac794c1b6b0 100644 --- a/Modules/sha1module.c +++ b/Modules/sha1module.c @@ -257,6 +257,7 @@ static PyType_Spec sha1_type_spec = { /* The single module-level function: new() */ /*[clinic input] +@text_signature "($module, /, data=b'', *, usedforsecurity=True)" _sha1.sha1 data: object(c_default="NULL") = b'' @@ -270,7 +271,7 @@ Return a new SHA1 hash object; optionally initialized with a string. static PyObject * _sha1_sha1_impl(PyObject *module, PyObject *data, int usedforsecurity, PyObject *string_obj) -/*[clinic end generated code: output=0d453775924f88a7 input=807f25264e0ac656]*/ +/*[clinic end generated code: output=0d453775924f88a7 input=c914f6827f065df8]*/ { SHA1object *new; Py_buffer buf; diff --git a/Modules/sha2module.c b/Modules/sha2module.c index d3801f2b4d232d..83162981673280 100644 --- a/Modules/sha2module.c +++ b/Modules/sha2module.c @@ -563,6 +563,7 @@ static PyType_Spec sha512_type_spec = { /* The module-level constructors. */ /*[clinic input] +@text_signature "($module, /, data=b'', *, usedforsecurity=True)" _sha2.sha256 data: object(c_default="NULL") = b'' @@ -576,7 +577,7 @@ Return a new SHA-256 hash object; optionally initialized with a string. static PyObject * _sha2_sha256_impl(PyObject *module, PyObject *data, int usedforsecurity, PyObject *string_obj) -/*[clinic end generated code: output=49828a7bcd418f45 input=9ce1d70e669abc14]*/ +/*[clinic end generated code: output=49828a7bcd418f45 input=7bf842e72bc924d3]*/ { Py_buffer buf; PyObject *string; @@ -622,6 +623,7 @@ _sha2_sha256_impl(PyObject *module, PyObject *data, int usedforsecurity, } /*[clinic input] +@text_signature "($module, /, data=b'', *, usedforsecurity=True)" _sha2.sha224 data: object(c_default="NULL") = b'' @@ -635,7 +637,7 @@ Return a new SHA-224 hash object; optionally initialized with a string. static PyObject * _sha2_sha224_impl(PyObject *module, PyObject *data, int usedforsecurity, PyObject *string_obj) -/*[clinic end generated code: output=2163cb03b6cf6157 input=612f7682a889bc2a]*/ +/*[clinic end generated code: output=2163cb03b6cf6157 input=65bb943f231cf024]*/ { Py_buffer buf; PyObject *string; @@ -680,6 +682,7 @@ _sha2_sha224_impl(PyObject *module, PyObject *data, int usedforsecurity, } /*[clinic input] +@text_signature "($module, /, data=b'', *, usedforsecurity=True)" _sha2.sha512 data: object(c_default="NULL") = b'' @@ -693,7 +696,7 @@ Return a new SHA-512 hash object; optionally initialized with a string. static PyObject * _sha2_sha512_impl(PyObject *module, PyObject *data, int usedforsecurity, PyObject *string_obj) -/*[clinic end generated code: output=cc3fcfce001a4538 input=19c9f2c06d59563a]*/ +/*[clinic end generated code: output=cc3fcfce001a4538 input=fef35e272416bcc3]*/ { SHA512object *new; Py_buffer buf; @@ -739,6 +742,7 @@ _sha2_sha512_impl(PyObject *module, PyObject *data, int usedforsecurity, } /*[clinic input] +@text_signature "($module, /, data=b'', *, usedforsecurity=True)" _sha2.sha384 data: object(c_default="NULL") = b'' @@ -752,7 +756,7 @@ Return a new SHA-384 hash object; optionally initialized with a string. static PyObject * _sha2_sha384_impl(PyObject *module, PyObject *data, int usedforsecurity, PyObject *string_obj) -/*[clinic end generated code: output=b6e3db593b5a0330 input=9fd50c942ad9e0bf]*/ +/*[clinic end generated code: output=b6e3db593b5a0330 input=024878e519d6f180]*/ { SHA512object *new; Py_buffer buf; diff --git a/Modules/sha3module.c b/Modules/sha3module.c index f0cb60d04caac7..80fd2ada3493c3 100644 --- a/Modules/sha3module.c +++ b/Modules/sha3module.c @@ -129,6 +129,7 @@ sha3_update(Hacl_Hash_SHA3_state_t *state, uint8_t *buf, Py_ssize_t len) /*[clinic input] @classmethod +@text_signature "(data=b'', *, usedforsecurity=True)" _sha3.sha3_224.__new__ as py_sha3_new data as data_obj: object(c_default="NULL") = b'' @@ -142,7 +143,7 @@ Return a new SHA3 hash object. static PyObject * py_sha3_new_impl(PyTypeObject *type, PyObject *data_obj, int usedforsecurity, PyObject *string) -/*[clinic end generated code: output=dcec1eca20395f2a input=c106e0b4e2d67d58]*/ +/*[clinic end generated code: output=dcec1eca20395f2a input=4f60c5ccf0ad0734]*/ { PyObject *data; if (_Py_hashlib_data_argument(&data, data_obj, string) < 0) {