summaryrefslogtreecommitdiffstats
path: root/Modules/_blake2/blake2s_impl.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-07-26 10:22:16 (GMT)
committerGitHub <noreply@github.com>2018-07-26 10:22:16 (GMT)
commit7cb7bcff20a386bba59cbc51e2419542de358bd2 (patch)
treef5d46faf7a7ddd3b427de7de8a74a1fb37fe2993 /Modules/_blake2/blake2s_impl.c
parent323748ad7446c76972c80dbbf510534dc5c22ae8 (diff)
downloadcpython-7cb7bcff20a386bba59cbc51e2419542de358bd2.zip
cpython-7cb7bcff20a386bba59cbc51e2419542de358bd2.tar.gz
cpython-7cb7bcff20a386bba59cbc51e2419542de358bd2.tar.bz2
bpo-20260: Implement non-bitwise unsigned int converters for Argument Clinic. (GH-8434)
Diffstat (limited to 'Modules/_blake2/blake2s_impl.c')
-rw-r--r--Modules/_blake2/blake2s_impl.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/Modules/_blake2/blake2s_impl.c b/Modules/_blake2/blake2s_impl.c
index 3b76c9c..8c49082 100644
--- a/Modules/_blake2/blake2s_impl.c
+++ b/Modules/_blake2/blake2s_impl.c
@@ -75,8 +75,8 @@ _blake2s.blake2s.__new__ as py_blake2s_new
person: Py_buffer = None
fanout: int = 1
depth: int = 1
- leaf_size as leaf_size_obj: object = NULL
- node_offset as node_offset_obj: object = NULL
+ leaf_size: unsigned_long = 0
+ node_offset: unsigned_long_long = 0
node_depth: int = 0
inner_size: int = 0
last_node: bool = False
@@ -87,17 +87,14 @@ Return a new BLAKE2s hash object.
static PyObject *
py_blake2s_new_impl(PyTypeObject *type, PyObject *data, int digest_size,
Py_buffer *key, Py_buffer *salt, Py_buffer *person,
- int fanout, int depth, PyObject *leaf_size_obj,
- PyObject *node_offset_obj, int node_depth,
+ int fanout, int depth, unsigned long leaf_size,
+ unsigned long long node_offset, int node_depth,
int inner_size, int last_node)
-/*[clinic end generated code: output=fe060b258a8cbfc6 input=458cfdcb3d0d47ff]*/
+/*[clinic end generated code: output=b95806be0514dcf7 input=f18d6efd9b9a1271]*/
{
BLAKE2sObject *self = NULL;
Py_buffer buf;
- unsigned long leaf_size = 0;
- unsigned long long node_offset = 0;
-
self = new_BLAKE2sObject(type);
if (self == NULL) {
goto error;
@@ -152,25 +149,13 @@ py_blake2s_new_impl(PyTypeObject *type, PyObject *data, int digest_size,
}
self->param.depth = (uint8_t)depth;
- if (leaf_size_obj != NULL) {
- leaf_size = PyLong_AsUnsignedLong(leaf_size_obj);
- if (leaf_size == (unsigned long) -1 && PyErr_Occurred()) {
- goto error;
- }
- if (leaf_size > 0xFFFFFFFFU) {
- PyErr_SetString(PyExc_OverflowError, "leaf_size is too large");
- goto error;
- }
+ if (leaf_size > 0xFFFFFFFFU) {
+ PyErr_SetString(PyExc_OverflowError, "leaf_size is too large");
+ goto error;
}
// NB: Simple assignment here would be incorrect on big endian platforms.
store32(&(self->param.leaf_length), leaf_size);
- if (node_offset_obj != NULL) {
- node_offset = PyLong_AsUnsignedLongLong(node_offset_obj);
- if (node_offset == (unsigned long long) -1 && PyErr_Occurred()) {
- goto error;
- }
- }
#ifdef HAVE_BLAKE2S
if (node_offset > 0xFFFFFFFFFFFFULL) {
/* maximum 2**48 - 1 */