From 1f00742141089ad2994b39072d877906907c38c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Thu, 22 Oct 2026 14:58:19 -0700 Subject: [PATCH] gh-160333: deprecate BLAKE-2 tree hashing parameters The tree hashing parameters *fanout*, *depth*, *leaf_size*, *node_offset*, *node_depth*, *inner_size* and *last_node* of `hashlib.blake2b` and `hashlib.blake2s` are now deprecated. Removal is scheduled for Python 3.21. --- Doc/deprecations/pending-removal-in-3.21.rst | 8 + Doc/library/hashlib.rst | 65 +++--- Doc/whatsnew/3.16.rst | 8 + Lib/test/test_hashlib.py | 216 ++++++++++++------ ...-10-22-13-28-10.gh-issue-160333.rRrDNx.rst | 4 + Modules/blake2module.c | 32 +-- Modules/clinic/blake2module.c.h | 108 ++++++++- 7 files changed, 329 insertions(+), 112 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2026-10-22-13-28-10.gh-issue-160333.rRrDNx.rst diff --git a/Doc/deprecations/pending-removal-in-3.21.rst b/Doc/deprecations/pending-removal-in-3.21.rst index 9fd0cd15aac547..46b1dcee9f1f2e 100644 --- a/Doc/deprecations/pending-removal-in-3.21.rst +++ b/Doc/deprecations/pending-removal-in-3.21.rst @@ -27,6 +27,14 @@ Pending removal in Python 3.21 parameter or pass the dispatch type explicitly instead. (Contributed by Bartosz Sławecki in :gh:`143465`.) +* :mod:`hashlib`: + + * The tree hashing parameters of :func:`~hashlib.blake2b` and + :func:`~hashlib.blake2s`, namely *fanout*, *depth*, *leaf_size*, + *node_offset*, *node_depth*, *inner_size* and *last_node*, are + deprecated since Python 3.16 and slated for removal in Python 3.21. + (Contributed by Bénédikt Tran in :gh:`160333`.) + * :mod:`struct`: * Soft-deprecated since Python 3.15, using ``'F'`` and ``'D'`` type codes are now diff --git a/Doc/library/hashlib.rst b/Doc/library/hashlib.rst index 5b666c5adac645..f15fd61f9d74e4 100644 --- a/Doc/library/hashlib.rst +++ b/Doc/library/hashlib.rst @@ -452,35 +452,6 @@ BLAKE2s 32 32 8 8 These sizes are available as module `constants`_ described below. -Constructor functions also accept the following tree hashing parameters: - -* *fanout*: fanout (0 to 255, 0 if unlimited, 1 in sequential mode). - -* *depth*: maximal depth of tree (1 to 255, 255 if unlimited, 1 in - sequential mode). - -* *leaf_size*: maximal byte length of leaf (0 to ``2**32-1``, 0 if unlimited or in - sequential mode). - -* *node_offset*: node offset (0 to ``2**64-1`` for BLAKE2b, 0 to ``2**48-1`` for - BLAKE2s, 0 for the first, leftmost, leaf, or in sequential mode). - -* *node_depth*: node depth (0 to 255, 0 for leaves, or in sequential mode). - -* *inner_size*: inner digest size (0 to 64 for BLAKE2b, 0 to 32 for - BLAKE2s, 0 in sequential mode). - -* *last_node*: boolean indicating whether the processed node is the last - one (``False`` for sequential mode). - -.. figure:: hashlib-blake2-tree.png - :alt: Explanation of tree mode parameters. - :class: invert-in-dark-mode - -See section 2.10 in `BLAKE2 specification -`_ for comprehensive review of tree -hashing. - Constants ^^^^^^^^^ @@ -739,6 +710,42 @@ keys from a single one. >>> print(b64encode(mac_key).decode('utf-8')) G9GtHFE1YluXY1zWPlYk1e/nWfu0WSEb0KRcjhDeP/o= + +Tree hashing +^^^^^^^^^^^^ + +.. deprecated-removed:: next 3.21 + The tree hashing parameters are deprecated. + +Constructor functions also accept the following tree hashing parameters: + +* *fanout*: fanout (0 to 255, 0 if unlimited, 1 in sequential mode). + +* *depth*: maximal depth of tree (1 to 255, 255 if unlimited, 1 in + sequential mode). + +* *leaf_size*: maximal byte length of leaf (0 to ``2**32-1``, 0 if unlimited or in + sequential mode). + +* *node_offset*: node offset (0 to ``2**64-1`` for BLAKE2b, 0 to ``2**48-1`` for + BLAKE2s, 0 for the first, leftmost, leaf, or in sequential mode). + +* *node_depth*: node depth (0 to 255, 0 for leaves, or in sequential mode). + +* *inner_size*: inner digest size (0 to 64 for BLAKE2b, 0 to 32 for + BLAKE2s, 0 in sequential mode). + +* *last_node*: boolean indicating whether the processed node is the last + one (``False`` for sequential mode). + +.. figure:: hashlib-blake2-tree.png + :alt: Explanation of tree mode parameters. + :class: invert-in-dark-mode + +See section 2.10 in `BLAKE2 specification +`_ for comprehensive review of tree +hashing. + Tree mode """"""""" diff --git a/Doc/whatsnew/3.16.rst b/Doc/whatsnew/3.16.rst index 7995da01285824..0d88a3774c734d 100644 --- a/Doc/whatsnew/3.16.rst +++ b/Doc/whatsnew/3.16.rst @@ -1154,6 +1154,14 @@ New deprecations instead. (Contributed by Bartosz Sławecki in :gh:`143465`.) +* :mod:`hashlib`: + + * The tree hashing parameters of :func:`~hashlib.blake2b` and + :func:`~hashlib.blake2s`, namely *fanout*, *depth*, *leaf_size*, + *node_offset*, *node_depth*, *inner_size* and *last_node*, are now + deprecated and slated for removal in Python 3.21. + (Contributed by Bénédikt Tran in :gh:`160333`.) + * :mod:`struct`: * The ``'F'`` and ``'D'`` type codes, soft-deprecated since Python 3.15, diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index a718be415b9905..f4df192e77c289 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -26,6 +26,7 @@ from test.support.import_helper import import_fresh_module from test.support import requires_resource from test.support import threading_helper +from test.support import warnings_helper from http.client import HTTPException @@ -125,6 +126,27 @@ def read_vectors(hash_name): ) +def deprecated_blake2_tree_parameter(hash_name, name): + return re.escape( + f"Passing the argument {name!r} to _blake2.{hash_name}() is " + "deprecated. It will be removed in Python 3.21." + ) + + +BLAKE2_TREE_PARAMETERS = ( + 'fanout', 'depth', 'leaf_size', 'node_offset', + 'node_depth', 'inner_size', 'last_node', +) + + +def check_blake2_tree_parameters_deprecated(hash_name): + # each tree hashing parameter emits its own warning + return warnings_helper.check_warnings(*( + (deprecated_blake2_tree_parameter(hash_name, name), DeprecationWarning) + for name in BLAKE2_TREE_PARAMETERS + )) + + class HashLibTestCase(unittest.TestCase): supported_hash_names = ( 'md5', 'MD5', 'sha1', 'SHA1', 'sha224', 'SHA224', 'sha256', 'SHA256', @@ -865,53 +887,84 @@ def check_blake2(self, constructor, salt_size, person_size, key_size, self.assertEqual(constructor().hexdigest(), constructor(key=b'').hexdigest()) + hash_name = constructor.__name__ + msg = deprecated_blake2_tree_parameter(hash_name, 'fanout') for i in range(0, 256): - constructor(fanout=i) - self.assertRaises(ValueError, constructor, fanout=-1) - self.assertRaises(ValueError, constructor, fanout=256) - + with self.assertWarnsRegex(DeprecationWarning, msg): + constructor(fanout=i) + with self.assertWarnsRegex(DeprecationWarning, msg): + self.assertRaises(ValueError, constructor, fanout=-1) + with self.assertWarnsRegex(DeprecationWarning, msg): + self.assertRaises(ValueError, constructor, fanout=256) + + msg = deprecated_blake2_tree_parameter(hash_name, 'depth') for i in range(1, 256): - constructor(depth=i) - self.assertRaises(ValueError, constructor, depth=-1) - self.assertRaises(ValueError, constructor, depth=0) - self.assertRaises(ValueError, constructor, depth=256) - + with self.assertWarnsRegex(DeprecationWarning, msg): + constructor(depth=i) + with self.assertWarnsRegex(DeprecationWarning, msg): + self.assertRaises(ValueError, constructor, depth=-1) + with self.assertWarnsRegex(DeprecationWarning, msg): + self.assertRaises(ValueError, constructor, depth=0) + with self.assertWarnsRegex(DeprecationWarning, msg): + self.assertRaises(ValueError, constructor, depth=256) + + msg = deprecated_blake2_tree_parameter(hash_name, 'node_depth') for i in range(0, 256): - constructor(node_depth=i) - self.assertRaises(ValueError, constructor, node_depth=-1) - self.assertRaises(ValueError, constructor, node_depth=256) - + with self.assertWarnsRegex(DeprecationWarning, msg): + constructor(node_depth=i) + with self.assertWarnsRegex(DeprecationWarning, msg): + self.assertRaises(ValueError, constructor, node_depth=-1) + with self.assertWarnsRegex(DeprecationWarning, msg): + self.assertRaises(ValueError, constructor, node_depth=256) + + msg = deprecated_blake2_tree_parameter(hash_name, 'inner_size') for i in range(0, digest_size + 1): - constructor(inner_size=i) - self.assertRaises(ValueError, constructor, inner_size=-1) - self.assertRaises(ValueError, constructor, inner_size=digest_size+1) - - constructor(leaf_size=0) - constructor(leaf_size=(1<<32)-1) - self.assertRaises(ValueError, constructor, leaf_size=-1) - self.assertRaises(OverflowError, constructor, leaf_size=1<<32) - - constructor(node_offset=0) - constructor(node_offset=max_offset) - self.assertRaises(ValueError, constructor, node_offset=-1) - self.assertRaises(OverflowError, constructor, node_offset=max_offset+1) + with self.assertWarnsRegex(DeprecationWarning, msg): + constructor(inner_size=i) + with self.assertWarnsRegex(DeprecationWarning, msg): + self.assertRaises(ValueError, constructor, inner_size=-1) + with self.assertWarnsRegex(DeprecationWarning, msg): + self.assertRaises(ValueError, constructor, + inner_size=digest_size+1) + + msg = deprecated_blake2_tree_parameter(hash_name, 'leaf_size') + with self.assertWarnsRegex(DeprecationWarning, msg): + constructor(leaf_size=0) + with self.assertWarnsRegex(DeprecationWarning, msg): + constructor(leaf_size=(1<<32)-1) + with self.assertWarnsRegex(DeprecationWarning, msg): + self.assertRaises(ValueError, constructor, leaf_size=-1) + with self.assertWarnsRegex(DeprecationWarning, msg): + self.assertRaises(OverflowError, constructor, leaf_size=1<<32) + + msg = deprecated_blake2_tree_parameter(hash_name, 'node_offset') + with self.assertWarnsRegex(DeprecationWarning, msg): + constructor(node_offset=0) + with self.assertWarnsRegex(DeprecationWarning, msg): + constructor(node_offset=max_offset) + with self.assertWarnsRegex(DeprecationWarning, msg): + self.assertRaises(ValueError, constructor, node_offset=-1) + with self.assertWarnsRegex(DeprecationWarning, msg): + self.assertRaises(OverflowError, constructor, + node_offset=max_offset+1) self.assertRaises(TypeError, constructor, '') - constructor( - b'', - key=b'', - salt=b'', - person=b'', - digest_size=17, - fanout=1, - depth=1, - leaf_size=256, - node_offset=512, - node_depth=1, - inner_size=7, - last_node=True - ) + with check_blake2_tree_parameters_deprecated(hash_name): + constructor( + b'', + key=b'', + salt=b'', + person=b'', + digest_size=17, + fanout=1, + depth=1, + leaf_size=256, + node_offset=512, + node_depth=1, + inner_size=7, + last_node=True + ) def blake2_rfc7693(self, constructor, md_len, in_len): def selftest_seq(length, seed): @@ -960,19 +1013,20 @@ def test_case_blake2b_1(self): def test_case_blake2b_all_parameters(self): # This checks that all the parameters work in general, and also that # parameter byte order doesn't get confused on big endian platforms. - self.check('blake2b', b"foo", - "920568b0c5873b2f0ab67bedb6cf1b2b", - digest_size=16, - key=b"bar", - salt=b"baz", - person=b"bing", - fanout=2, - depth=3, - leaf_size=4, - node_offset=5, - node_depth=6, - inner_size=7, - last_node=True) + with check_blake2_tree_parameters_deprecated('blake2b'): + self.check('blake2b', b"foo", + "920568b0c5873b2f0ab67bedb6cf1b2b", + digest_size=16, + key=b"bar", + salt=b"baz", + person=b"bing", + fanout=2, + depth=3, + leaf_size=4, + node_offset=5, + node_depth=6, + inner_size=7, + last_node=True) @requires_blake2 def test_blake2b_vectors(self): @@ -1003,19 +1057,20 @@ def test_case_blake2s_1(self): def test_case_blake2s_all_parameters(self): # This checks that all the parameters work in general, and also that # parameter byte order doesn't get confused on big endian platforms. - self.check('blake2s', b"foo", - "bf2a8f7fe3c555012a6f8046e646bc75", - digest_size=16, - key=b"bar", - salt=b"baz", - person=b"bing", - fanout=2, - depth=3, - leaf_size=4, - node_offset=5, - node_depth=6, - inner_size=7, - last_node=True) + with check_blake2_tree_parameters_deprecated('blake2s'): + self.check('blake2s', b"foo", + "bf2a8f7fe3c555012a6f8046e646bc75", + digest_size=16, + key=b"bar", + salt=b"baz", + person=b"bing", + fanout=2, + depth=3, + leaf_size=4, + node_offset=5, + node_depth=6, + inner_size=7, + last_node=True) @requires_blake2 def test_blake2s_vectors(self): @@ -1023,6 +1078,35 @@ def test_blake2s_vectors(self): key = bytes.fromhex(key) self.check('blake2s', msg, md, key=key) + @requires_blake2 + @support.subTests("name", ["blake2b", "blake2s"]) + @support.subTests("parameter, value", [ + ("fanout", 1), + ("depth", 1), + ("leaf_size", 0), + ("node_offset", 0), + ("node_depth", 0), + ("inner_size", 0), + ("last_node", False), + ]) + def test_blake2_tree_parameter_deprecated(self, name, parameter, value): + constructor = getattr(hashlib, name) + msg = deprecated_blake2_tree_parameter(name, parameter) + kwargs = {parameter: value} + with self.assertWarnsRegex(DeprecationWarning, msg): + constructor(**kwargs) + with self.assertWarnsRegex(DeprecationWarning, msg): + hashlib.new(name, **kwargs) + + @requires_blake2 + @support.subTests("name", ["blake2b", "blake2s"]) + def test_blake2_tree_parameters_omitted(self, name): + constructor = getattr(hashlib, name) + with warnings_helper.check_no_warnings(self, + category=DeprecationWarning): + constructor(b'data', digest_size=16, key=b'key') + hashlib.new(name, b'data', digest_size=16, key=b'key') + @requires_sha3 def test_case_sha3_224_0(self): self.check('sha3_224', b"", diff --git a/Misc/NEWS.d/next/Library/2026-10-22-13-28-10.gh-issue-160333.rRrDNx.rst b/Misc/NEWS.d/next/Library/2026-10-22-13-28-10.gh-issue-160333.rRrDNx.rst new file mode 100644 index 00000000000000..401445ed61955e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-22-13-28-10.gh-issue-160333.rRrDNx.rst @@ -0,0 +1,4 @@ +:mod:`hashlib`: Passing the tree hashing parameters *fanout*, *depth*, +*leaf_size*, *node_offset*, *node_depth*, *inner_size* and *last_node* to +:func:`~hashlib.blake2b` and :func:`~hashlib.blake2s` is now deprecated and +slated for removal in Python 3.21. Patch by Bénédikt Tran. diff --git a/Modules/blake2module.c b/Modules/blake2module.c index 551ebd7cd052af..82337e89899fa7 100644 --- a/Modules/blake2module.c +++ b/Modules/blake2module.c @@ -673,13 +673,13 @@ _blake2.blake2b.__new__ as py_blake2b_new key: Py_buffer = b'' salt: Py_buffer = b'' person: Py_buffer = b'' - fanout: int = 1 - depth: int = 1 - leaf_size: unsigned_long = 0 - node_offset: unsigned_long_long = 0 - node_depth: int = 0 - inner_size: int = 0 - last_node: bool = False + [until 3.21] fanout: int = 1 + [until 3.21] depth: int = 1 + [until 3.21] leaf_size: unsigned_long = 0 + [until 3.21] node_offset: unsigned_long_long = 0 + [until 3.21] node_depth: int = 0 + [until 3.21] inner_size: int = 0 + [until 3.21] last_node: bool = False usedforsecurity: bool = True string: object(c_default="NULL") = None @@ -693,7 +693,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=6b22e77641eaf479]*/ { PyObject *data; if (_Py_hashlib_data_argument(&data, data_obj, string) < 0) { @@ -713,13 +713,13 @@ _blake2.blake2s.__new__ as py_blake2s_new key: Py_buffer = b'' salt: Py_buffer = b'' person: Py_buffer = b'' - fanout: int = 1 - depth: int = 1 - leaf_size: unsigned_long = 0 - node_offset: unsigned_long_long = 0 - node_depth: int = 0 - inner_size: int = 0 - last_node: bool = False + [until 3.21] fanout: int = 1 + [until 3.21] depth: int = 1 + [until 3.21] leaf_size: unsigned_long = 0 + [until 3.21] node_offset: unsigned_long_long = 0 + [until 3.21] node_depth: int = 0 + [until 3.21] inner_size: int = 0 + [until 3.21] last_node: bool = False usedforsecurity: bool = True string: object(c_default="NULL") = None @@ -733,7 +733,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=d02f308a331f607f]*/ { PyObject *data; if (_Py_hashlib_data_argument(&data, data_obj, string) < 0) { diff --git a/Modules/clinic/blake2module.c.h b/Modules/clinic/blake2module.c.h index dc70abfaf05543..13a33a8a537ba6 100644 --- a/Modules/clinic/blake2module.c.h +++ b/Modules/clinic/blake2module.c.h @@ -26,6 +26,17 @@ py_blake2b_new_impl(PyTypeObject *type, PyObject *data_obj, int digest_size, int inner_size, int last_node, int usedforsecurity, PyObject *string); +// Emit compiler warnings when we get to Python 3.21. +#if PY_VERSION_HEX >= 0x031500C0 +# error "Update the clinic input of '_blake2.blake2b.__new__'." +#elif PY_VERSION_HEX >= 0x031500A0 +# ifdef _MSC_VER +# pragma message ("Update the clinic input of '_blake2.blake2b.__new__'.") +# else +# warning "Update the clinic input of '_blake2.blake2b.__new__'." +# endif +#endif + static PyObject * py_blake2b_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { @@ -128,6 +139,12 @@ py_blake2b_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } } if (fastargs[5]) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Passing the argument 'fanout' to _blake2.blake2b() is " + "deprecated. It will be removed in Python 3.21.", 1)) + { + goto exit; + } fanout = PyLong_AsInt(fastargs[5]); if (fanout == -1 && PyErr_Occurred()) { goto exit; @@ -137,6 +154,12 @@ py_blake2b_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } } if (fastargs[6]) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Passing the argument 'depth' to _blake2.blake2b() is deprecated." + " It will be removed in Python 3.21.", 1)) + { + goto exit; + } depth = PyLong_AsInt(fastargs[6]); if (depth == -1 && PyErr_Occurred()) { goto exit; @@ -146,6 +169,12 @@ py_blake2b_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } } if (fastargs[7]) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Passing the argument 'leaf_size' to _blake2.blake2b() is " + "deprecated. It will be removed in Python 3.21.", 1)) + { + goto exit; + } if (!_PyLong_UnsignedLong_Converter(fastargs[7], &leaf_size)) { goto exit; } @@ -154,6 +183,12 @@ py_blake2b_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } } if (fastargs[8]) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Passing the argument 'node_offset' to _blake2.blake2b() is " + "deprecated. It will be removed in Python 3.21.", 1)) + { + goto exit; + } if (!_PyLong_UnsignedLongLong_Converter(fastargs[8], &node_offset)) { goto exit; } @@ -162,6 +197,12 @@ py_blake2b_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } } if (fastargs[9]) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Passing the argument 'node_depth' to _blake2.blake2b() is " + "deprecated. It will be removed in Python 3.21.", 1)) + { + goto exit; + } node_depth = PyLong_AsInt(fastargs[9]); if (node_depth == -1 && PyErr_Occurred()) { goto exit; @@ -171,6 +212,12 @@ py_blake2b_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } } if (fastargs[10]) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Passing the argument 'inner_size' to _blake2.blake2b() is " + "deprecated. It will be removed in Python 3.21.", 1)) + { + goto exit; + } inner_size = PyLong_AsInt(fastargs[10]); if (inner_size == -1 && PyErr_Occurred()) { goto exit; @@ -180,6 +227,12 @@ py_blake2b_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } } if (fastargs[11]) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Passing the argument 'last_node' to _blake2.blake2b() is " + "deprecated. It will be removed in Python 3.21.", 1)) + { + goto exit; + } last_node = PyObject_IsTrue(fastargs[11]); if (last_node < 0) { goto exit; @@ -235,6 +288,17 @@ py_blake2s_new_impl(PyTypeObject *type, PyObject *data_obj, int digest_size, int inner_size, int last_node, int usedforsecurity, PyObject *string); +// Emit compiler warnings when we get to Python 3.21. +#if PY_VERSION_HEX >= 0x031500C0 +# error "Update the clinic input of '_blake2.blake2s.__new__'." +#elif PY_VERSION_HEX >= 0x031500A0 +# ifdef _MSC_VER +# pragma message ("Update the clinic input of '_blake2.blake2s.__new__'.") +# else +# warning "Update the clinic input of '_blake2.blake2s.__new__'." +# endif +#endif + static PyObject * py_blake2s_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { @@ -337,6 +401,12 @@ py_blake2s_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } } if (fastargs[5]) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Passing the argument 'fanout' to _blake2.blake2s() is " + "deprecated. It will be removed in Python 3.21.", 1)) + { + goto exit; + } fanout = PyLong_AsInt(fastargs[5]); if (fanout == -1 && PyErr_Occurred()) { goto exit; @@ -346,6 +416,12 @@ py_blake2s_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } } if (fastargs[6]) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Passing the argument 'depth' to _blake2.blake2s() is deprecated." + " It will be removed in Python 3.21.", 1)) + { + goto exit; + } depth = PyLong_AsInt(fastargs[6]); if (depth == -1 && PyErr_Occurred()) { goto exit; @@ -355,6 +431,12 @@ py_blake2s_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } } if (fastargs[7]) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Passing the argument 'leaf_size' to _blake2.blake2s() is " + "deprecated. It will be removed in Python 3.21.", 1)) + { + goto exit; + } if (!_PyLong_UnsignedLong_Converter(fastargs[7], &leaf_size)) { goto exit; } @@ -363,6 +445,12 @@ py_blake2s_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } } if (fastargs[8]) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Passing the argument 'node_offset' to _blake2.blake2s() is " + "deprecated. It will be removed in Python 3.21.", 1)) + { + goto exit; + } if (!_PyLong_UnsignedLongLong_Converter(fastargs[8], &node_offset)) { goto exit; } @@ -371,6 +459,12 @@ py_blake2s_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } } if (fastargs[9]) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Passing the argument 'node_depth' to _blake2.blake2s() is " + "deprecated. It will be removed in Python 3.21.", 1)) + { + goto exit; + } node_depth = PyLong_AsInt(fastargs[9]); if (node_depth == -1 && PyErr_Occurred()) { goto exit; @@ -380,6 +474,12 @@ py_blake2s_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } } if (fastargs[10]) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Passing the argument 'inner_size' to _blake2.blake2s() is " + "deprecated. It will be removed in Python 3.21.", 1)) + { + goto exit; + } inner_size = PyLong_AsInt(fastargs[10]); if (inner_size == -1 && PyErr_Occurred()) { goto exit; @@ -389,6 +489,12 @@ py_blake2s_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } } if (fastargs[11]) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Passing the argument 'last_node' to _blake2.blake2s() is " + "deprecated. It will be removed in Python 3.21.", 1)) + { + goto exit; + } last_node = PyObject_IsTrue(fastargs[11]); if (last_node < 0) { goto exit; @@ -506,4 +612,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=02670545d7f300f6 input=a9049054013a1b77]*/