@@ -387,14 +387,14 @@ PyDoc_STRVAR(SHA1_update__doc__,
387387static PyObject *
388388SHA1_update (SHA1object * self , PyObject * args )
389389{
390- unsigned char * cp ;
391- int len ;
390+ Py_buffer buf ;
392391
393- if (!PyArg_ParseTuple (args , "s# :update" , & cp , & len ))
392+ if (!PyArg_ParseTuple (args , "s* :update" , & buf ))
394393 return NULL ;
395394
396- sha1_process (& self -> hash_state , cp , len );
395+ sha1_process (& self -> hash_state , buf . buf , buf . len );
397396
397+ PyBuffer_Release (& buf );
398398 Py_INCREF (Py_None );
399399 return Py_None ;
400400}
@@ -487,11 +487,10 @@ SHA1_new(PyObject *self, PyObject *args, PyObject *kwdict)
487487{
488488 static char * kwlist [] = {"string" , NULL };
489489 SHA1object * new ;
490- unsigned char * cp = NULL ;
491- int len ;
490+ Py_buffer buf ;
492491
493- if (!PyArg_ParseTupleAndKeywords (args , kwdict , "|s# :new" , kwlist ,
494- & cp , & len )) {
492+ if (!PyArg_ParseTupleAndKeywords (args , kwdict , "|s* :new" , kwlist ,
493+ & buf )) {
495494 return NULL ;
496495 }
497496
@@ -504,8 +503,10 @@ SHA1_new(PyObject *self, PyObject *args, PyObject *kwdict)
504503 Py_DECREF (new );
505504 return NULL ;
506505 }
507- if (cp )
508- sha1_process (& new -> hash_state , cp , len );
506+ if (buf .buf ) {
507+ sha1_process (& new -> hash_state , buf .buf , buf .len );
508+ PyBuffer_Release (& buf );
509+ }
509510
510511 return (PyObject * )new ;
511512}
0 commit comments