diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2008-08-14 15:52:23 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2008-08-14 15:52:23 (GMT) |
commit | 7b9cb2579c7edf49e4042bfb678ae2dc646d78ef (patch) | |
tree | b83b0319cf4bfe2e44b39e79609ecd54796176fa | |
parent | 42b2f2ec78cc80b0863073343e5ee8f041ea37dc (diff) | |
download | cpython-7b9cb2579c7edf49e4042bfb678ae2dc646d78ef.zip cpython-7b9cb2579c7edf49e4042bfb678ae2dc646d78ef.tar.gz cpython-7b9cb2579c7edf49e4042bfb678ae2dc646d78ef.tar.bz2 |
Use s* to receive data. Fixes #3552.
-rw-r--r-- | Modules/md5module.c | 24 | ||||
-rw-r--r-- | Modules/sha1module.c | 21 |
2 files changed, 24 insertions, 21 deletions
diff --git a/Modules/md5module.c b/Modules/md5module.c index f024b73..0f3c6d9 100644 --- a/Modules/md5module.c +++ b/Modules/md5module.c @@ -411,14 +411,14 @@ PyDoc_STRVAR(MD5_update__doc__, static PyObject * MD5_update(MD5object *self, PyObject *args) { - unsigned char *cp; - int len; - - if (!PyArg_ParseTuple(args, "s#:update", &cp, &len)) + Py_buffer buf; + + if (!PyArg_ParseTuple(args, "s*:update", &buf)) return NULL; - md5_process(&self->hash_state, cp, len); + md5_process(&self->hash_state, buf.buf, buf.len); + PyBuffer_Release(&buf); Py_INCREF(Py_None); return Py_None; } @@ -511,11 +511,11 @@ MD5_new(PyObject *self, PyObject *args, PyObject *kwdict) { static char *kwlist[] = {"string", NULL}; MD5object *new; - unsigned char *cp = NULL; - int len; + Py_buffer buf; + buf.buf = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwdict, "|s#:new", kwlist, - &cp, &len)) { + if (!PyArg_ParseTupleAndKeywords(args, kwdict, "|s*:new", kwlist, + &buf)) { return NULL; } @@ -528,8 +528,10 @@ MD5_new(PyObject *self, PyObject *args, PyObject *kwdict) Py_DECREF(new); return NULL; } - if (cp) - md5_process(&new->hash_state, cp, len); + if (buf.buf) { + md5_process(&new->hash_state, buf.buf, buf.len); + PyBuffer_Release(&buf); + } return (PyObject *)new; } diff --git a/Modules/sha1module.c b/Modules/sha1module.c index 2cbfb50..b21b21d 100644 --- a/Modules/sha1module.c +++ b/Modules/sha1module.c @@ -387,14 +387,14 @@ PyDoc_STRVAR(SHA1_update__doc__, static PyObject * SHA1_update(SHA1object *self, PyObject *args) { - unsigned char *cp; - int len; + Py_buffer buf; - if (!PyArg_ParseTuple(args, "s#:update", &cp, &len)) + if (!PyArg_ParseTuple(args, "s*:update", &buf)) return NULL; - sha1_process(&self->hash_state, cp, len); + sha1_process(&self->hash_state, buf.buf, buf.len); + PyBuffer_Release(&buf); Py_INCREF(Py_None); return Py_None; } @@ -487,11 +487,10 @@ SHA1_new(PyObject *self, PyObject *args, PyObject *kwdict) { static char *kwlist[] = {"string", NULL}; SHA1object *new; - unsigned char *cp = NULL; - int len; + Py_buffer buf; - if (!PyArg_ParseTupleAndKeywords(args, kwdict, "|s#:new", kwlist, - &cp, &len)) { + if (!PyArg_ParseTupleAndKeywords(args, kwdict, "|s*:new", kwlist, + &buf)) { return NULL; } @@ -504,8 +503,10 @@ SHA1_new(PyObject *self, PyObject *args, PyObject *kwdict) Py_DECREF(new); return NULL; } - if (cp) - sha1_process(&new->hash_state, cp, len); + if (buf.buf) { + sha1_process(&new->hash_state, buf.buf, buf.len); + PyBuffer_Release(&buf); + } return (PyObject *)new; } |