@@ -75,7 +75,7 @@ imgfile_ttob(PyObject *self, PyObject *args)
7575 int newval ;
7676 PyObject * rv ;
7777
78- if (!PyArg_Parse (args , "i" , & newval ))
78+ if (!PyArg_ParseTuple (args , "i:ttob " , & newval ))
7979 return NULL ;
8080 rv = PyInt_FromLong (top_to_bottom );
8181 top_to_bottom = newval ;
@@ -95,7 +95,7 @@ imgfile_read(PyObject *self, PyObject *args)
9595 IMAGE * image ;
9696 int yfirst , ylast , ystep ;
9797
98- if ( !PyArg_Parse (args , "s" , & fname ) )
98+ if ( !PyArg_ParseTuple (args , "s:read " , & fname ) )
9999 return NULL ;
100100
101101 if ( (image = imgfile_open (fname )) == NULL )
@@ -250,10 +250,9 @@ imgfile_readscaled(PyObject *self, PyObject *args)
250250 int x , y ;
251251 int xwtd , ywtd , xorig , yorig ;
252252 float xfac , yfac ;
253- int cnt ;
254253 IMAGE * image ;
255254 char * filter ;
256- double blur ;
255+ double blur = 1.0 ;
257256 int extended ;
258257 int fmode = 0 ;
259258 int yfirst , ylast , ystep ;
@@ -263,20 +262,9 @@ imgfile_readscaled(PyObject *self, PyObject *args)
263262 ** (filter name and blur factor). Also, 4 or 5 arguments indicates
264263 ** extended scale algorithm in stead of simple-minded pixel drop/dup.
265264 */
266- extended = 0 ;
267- cnt = PyTuple_Size (args );
268- if ( cnt == 5 ) {
269- extended = 1 ;
270- if ( !PyArg_Parse (args , "(siisd)" ,
271- & fname , & xwtd , & ywtd , & filter , & blur ) )
272- return NULL ;
273- } else if ( cnt == 4 ) {
274- extended = 1 ;
275- if ( !PyArg_Parse (args , "(siis)" ,
276- & fname , & xwtd , & ywtd , & filter ) )
277- return NULL ;
278- blur = 1.0 ;
279- } else if ( !PyArg_Parse (args , "(sii)" , & fname , & xwtd , & ywtd ) )
265+ extended = PyTuple_Size (args ) >= 4 ;
266+ if ( !PyArg_ParseTuple (args , "sii|sd" ,
267+ & fname , & xwtd , & ywtd , & filter , & blur ) )
280268 return NULL ;
281269
282270 /*
@@ -391,7 +379,7 @@ imgfile_getsizes(PyObject *self, PyObject *args)
391379 PyObject * rv ;
392380 IMAGE * image ;
393381
394- if ( !PyArg_Parse (args , "s" , & fname ) )
382+ if ( !PyArg_ParseTuple (args , "s:getsizes " , & fname ) )
395383 return NULL ;
396384
397385 if ( (image = imgfile_open (fname )) == NULL )
@@ -416,7 +404,7 @@ imgfile_write(PyObject *self, PyObject *args)
416404 int yfirst , ylast , ystep ;
417405
418406
419- if ( !PyArg_Parse (args , "( ss#iii) " ,
407+ if ( !PyArg_ParseTuple (args , "ss#iii:write " ,
420408 & fname , & cdatap , & len , & xsize , & ysize , & zsize ) )
421409 return NULL ;
422410
@@ -490,11 +478,11 @@ imgfile_write(PyObject *self, PyObject *args)
490478
491479
492480static PyMethodDef imgfile_methods [] = {
493- { "getsizes" , imgfile_getsizes , METH_OLDARGS },
494- { "read" , imgfile_read , METH_OLDARGS },
481+ { "getsizes" , imgfile_getsizes , METH_VARARGS },
482+ { "read" , imgfile_read , METH_VARARGS },
495483 { "readscaled" , imgfile_readscaled , METH_VARARGS },
496- { "write" , imgfile_write , METH_OLDARGS },
497- { "ttob" , imgfile_ttob , METH_OLDARGS },
484+ { "write" , imgfile_write , METH_VARARGS },
485+ { "ttob" , imgfile_ttob , METH_VARARGS },
498486 { NULL , NULL } /* Sentinel */
499487};
500488
0 commit comments