diff options
author | Georg Brandl <georg@python.org> | 2006-05-29 21:04:52 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-05-29 21:04:52 (GMT) |
commit | 96a8c3954cbdb186bc567a490dad8987508ce268 (patch) | |
tree | 4d6516790abcd566c43418e4c9b02e9c52cf9f2f /Modules/sha256module.c | |
parent | fd9a4b19e9c77e9ccc3e7fcb57051cf160c0df6d (diff) | |
download | cpython-96a8c3954cbdb186bc567a490dad8987508ce268.zip cpython-96a8c3954cbdb186bc567a490dad8987508ce268.tar.gz cpython-96a8c3954cbdb186bc567a490dad8987508ce268.tar.bz2 |
Make use of METH_O and METH_NOARGS where possible.
Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
Diffstat (limited to 'Modules/sha256module.c')
-rw-r--r-- | Modules/sha256module.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/Modules/sha256module.c b/Modules/sha256module.c index 7037ca0..0effb07 100644 --- a/Modules/sha256module.c +++ b/Modules/sha256module.c @@ -405,14 +405,10 @@ SHA_dealloc(PyObject *ptr) PyDoc_STRVAR(SHA256_copy__doc__, "Return a copy of the hash object."); static PyObject * -SHA256_copy(SHAobject *self, PyObject *args) +SHA256_copy(SHAobject *self, PyObject *unused) { SHAobject *newobj; - if (!PyArg_ParseTuple(args, ":copy")) { - return NULL; - } - if (((PyObject*)self)->ob_type == &SHA256type) { if ( (newobj = newSHA256object())==NULL) return NULL; @@ -429,14 +425,11 @@ PyDoc_STRVAR(SHA256_digest__doc__, "Return the digest value as a string of binary data."); static PyObject * -SHA256_digest(SHAobject *self, PyObject *args) +SHA256_digest(SHAobject *self, PyObject *unused) { unsigned char digest[SHA_DIGESTSIZE]; SHAobject temp; - if (!PyArg_ParseTuple(args, ":digest")) - return NULL; - SHAcopy(self, &temp); sha_final(digest, &temp); return PyString_FromStringAndSize((const char *)digest, self->digestsize); @@ -446,7 +439,7 @@ PyDoc_STRVAR(SHA256_hexdigest__doc__, "Return the digest value as a string of hexadecimal digits."); static PyObject * -SHA256_hexdigest(SHAobject *self, PyObject *args) +SHA256_hexdigest(SHAobject *self, PyObject *unused) { unsigned char digest[SHA_DIGESTSIZE]; SHAobject temp; @@ -454,9 +447,6 @@ SHA256_hexdigest(SHAobject *self, PyObject *args) char *hex_digest; int i, j; - if (!PyArg_ParseTuple(args, ":hexdigest")) - return NULL; - /* Get the raw (binary) digest value */ SHAcopy(self, &temp); sha_final(digest, &temp); @@ -503,9 +493,9 @@ SHA256_update(SHAobject *self, PyObject *args) } static PyMethodDef SHA_methods[] = { - {"copy", (PyCFunction)SHA256_copy, METH_VARARGS, SHA256_copy__doc__}, - {"digest", (PyCFunction)SHA256_digest, METH_VARARGS, SHA256_digest__doc__}, - {"hexdigest", (PyCFunction)SHA256_hexdigest, METH_VARARGS, SHA256_hexdigest__doc__}, + {"copy", (PyCFunction)SHA256_copy, METH_NOARGS, SHA256_copy__doc__}, + {"digest", (PyCFunction)SHA256_digest, METH_NOARGS, SHA256_digest__doc__}, + {"hexdigest", (PyCFunction)SHA256_hexdigest, METH_NOARGS, SHA256_hexdigest__doc__}, {"update", (PyCFunction)SHA256_update, METH_VARARGS, SHA256_update__doc__}, {NULL, NULL} /* sentinel */ }; |