Fix various minor errors in passing arguments to

PyArg_ParseTuple.
This commit is contained in:
Martin v. Löwis 2006-10-19 11:00:37 +00:00
parent aac1316222
commit a811c38d8e
4 changed files with 27 additions and 16 deletions

View file

@ -472,8 +472,12 @@ audioop_findfit(PyObject *self, PyObject *args)
double aj_m1, aj_lm1;
double sum_ri_2, sum_aij_2, sum_aij_ri, result, best_result, factor;
/* Passing a short** for an 's' argument is correct only
if the string contents is aligned for interpretation
as short[]. Due to the definition of PyStringObject,
this is currently (Python 2.6) the case. */
if ( !PyArg_ParseTuple(args, "s#s#:findfit",
&cp1, &len1, &cp2, &len2) )
(char**)&cp1, &len1, (char**)&cp2, &len2) )
return 0;
if ( len1 & 1 || len2 & 1 ) {
PyErr_SetString(AudioopError, "Strings should be even-sized");
@ -530,7 +534,7 @@ audioop_findfactor(PyObject *self, PyObject *args)
double sum_ri_2, sum_aij_ri, result;
if ( !PyArg_ParseTuple(args, "s#s#:findfactor",
&cp1, &len1, &cp2, &len2) )
(char**)&cp1, &len1, (char**)&cp2, &len2) )
return 0;
if ( len1 & 1 || len2 & 1 ) {
PyErr_SetString(AudioopError, "Strings should be even-sized");
@ -562,7 +566,8 @@ audioop_findmax(PyObject *self, PyObject *args)
double aj_m1, aj_lm1;
double result, best_result;
if ( !PyArg_ParseTuple(args, "s#i:findmax", &cp1, &len1, &len2) )
if ( !PyArg_ParseTuple(args, "s#i:findmax",
(char**)&cp1, &len1, &len2) )
return 0;
if ( len1 & 1 ) {
PyErr_SetString(AudioopError, "Strings should be even-sized");