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/sha512module.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/sha512module.c')
-rw-r--r-- | Modules/sha512module.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/Modules/sha512module.c b/Modules/sha512module.c index c5a85ff..9f47b61 100644 --- a/Modules/sha512module.c +++ b/Modules/sha512module.c @@ -471,14 +471,10 @@ SHA512_dealloc(PyObject *ptr) PyDoc_STRVAR(SHA512_copy__doc__, "Return a copy of the hash object."); static PyObject * -SHA512_copy(SHAobject *self, PyObject *args) +SHA512_copy(SHAobject *self, PyObject *unused) { SHAobject *newobj; - if (!PyArg_ParseTuple(args, ":copy")) { - return NULL; - } - if (((PyObject*)self)->ob_type == &SHA512type) { if ( (newobj = newSHA512object())==NULL) return NULL; @@ -495,14 +491,11 @@ PyDoc_STRVAR(SHA512_digest__doc__, "Return the digest value as a string of binary data."); static PyObject * -SHA512_digest(SHAobject *self, PyObject *args) +SHA512_digest(SHAobject *self, PyObject *unused) { unsigned char digest[SHA_DIGESTSIZE]; SHAobject temp; - if (!PyArg_ParseTuple(args, ":digest")) - return NULL; - SHAcopy(self, &temp); sha512_final(digest, &temp); return PyString_FromStringAndSize((const char *)digest, self->digestsize); @@ -512,7 +505,7 @@ PyDoc_STRVAR(SHA512_hexdigest__doc__, "Return the digest value as a string of hexadecimal digits."); static PyObject * -SHA512_hexdigest(SHAobject *self, PyObject *args) +SHA512_hexdigest(SHAobject *self, PyObject *unused) { unsigned char digest[SHA_DIGESTSIZE]; SHAobject temp; @@ -520,9 +513,6 @@ SHA512_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); sha512_final(digest, &temp); @@ -538,7 +528,7 @@ SHA512_hexdigest(SHAobject *self, PyObject *args) } /* Make hex version of the digest */ - for(i=j=0; i<self->digestsize; i++) { + for (i=j=0; i<self->digestsize; i++) { char c; c = (digest[i] >> 4) & 0xf; c = (c>9) ? c+'a'-10 : c + '0'; @@ -569,9 +559,9 @@ SHA512_update(SHAobject *self, PyObject *args) } static PyMethodDef SHA_methods[] = { - {"copy", (PyCFunction)SHA512_copy, METH_VARARGS, SHA512_copy__doc__}, - {"digest", (PyCFunction)SHA512_digest, METH_VARARGS, SHA512_digest__doc__}, - {"hexdigest", (PyCFunction)SHA512_hexdigest, METH_VARARGS, SHA512_hexdigest__doc__}, + {"copy", (PyCFunction)SHA512_copy, METH_NOARGS, SHA512_copy__doc__}, + {"digest", (PyCFunction)SHA512_digest, METH_NOARGS, SHA512_digest__doc__}, + {"hexdigest", (PyCFunction)SHA512_hexdigest, METH_NOARGS, SHA512_hexdigest__doc__}, {"update", (PyCFunction)SHA512_update, METH_VARARGS, SHA512_update__doc__}, {NULL, NULL} /* sentinel */ }; |