Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b0aaec5

Browse files
committed
Convert more METH_OLDARGS & PyArg_Parse()
Please review.
1 parent 187ae56 commit b0aaec5

3 files changed

Lines changed: 69 additions & 69 deletions

File tree

Modules/clmodule.c

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ cl_CompressImage(PyObject *self, PyObject *args)
104104
char *frameBuffer;
105105
PyObject *compressedBuffer;
106106

107-
if (!PyArg_Parse(args, "(iiiifs#)", &compressionScheme,
107+
if (!PyArg_ParseTuple(args, "iiiifs#", &compressionScheme,
108108
&width, &height,
109109
&originalFormat, &compressionRatio, &frameBuffer,
110110
&frameBufferSize))
@@ -149,7 +149,7 @@ cl_DecompressImage(PyObject *self, PyObject *args)
149149
int compressedBufferSize, frameBufferSize;
150150
PyObject *frameBuffer;
151151

152-
if (!PyArg_Parse(args, "(iiiis#)", &compressionScheme, &width, &height,
152+
if (!PyArg_ParseTuple(args, "iiiis#", &compressionScheme, &width, &height,
153153
&originalFormat, &compressedBuffer,
154154
&compressedBufferSize))
155155
return NULL;
@@ -670,7 +670,7 @@ doOpen(PyObject *self, PyObject *args, int (*open_func)(int, CL_Handle *),
670670
int scheme;
671671
clobject *new;
672672

673-
if (!PyArg_Parse(args, "i", &scheme))
673+
if (!PyArg_ParseTuple(args, "i", &scheme))
674674
return NULL;
675675

676676
new = PyObject_New(clobject, &Cltype);
@@ -711,7 +711,7 @@ cl_QueryScheme(PyObject *self, PyObject *args)
711711
int headerlen;
712712
int scheme;
713713

714-
if (!PyArg_Parse(args, "s#", &header, &headerlen))
714+
if (!PyArg_ParseTuple(args, "s#", &header, &headerlen))
715715
return NULL;
716716

717717
scheme = clQueryScheme(header);
@@ -728,7 +728,7 @@ cl_QueryMaxHeaderSize(PyObject *self, PyObject *args)
728728
{
729729
int scheme;
730730

731-
if (!PyArg_Parse(args, "i", &scheme))
731+
if (!PyArg_ParseTuple(args, "i", &scheme))
732732
return NULL;
733733

734734
return PyInt_FromLong(clQueryMaxHeaderSize(scheme));
@@ -743,7 +743,7 @@ cl_QueryAlgorithms(PyObject *self, PyObject *args)
743743
PyObject *list;
744744
int i;
745745

746-
if (!PyArg_Parse(args, "i", &algorithmMediaType))
746+
if (!PyArg_ParseTuple(args, "i", &algorithmMediaType))
747747
return NULL;
748748

749749
error_handler_called = 0;
@@ -791,7 +791,7 @@ cl_QuerySchemeFromName(PyObject *self, PyObject *args)
791791
char *name;
792792
int scheme;
793793

794-
if (!PyArg_Parse(args, "(is)", &algorithmMediaType, &name))
794+
if (!PyArg_ParseTuple(args, "is", &algorithmMediaType, &name))
795795
return NULL;
796796

797797
error_handler_called = 0;
@@ -810,7 +810,7 @@ cl_GetAlgorithmName(PyObject *self, PyObject *args)
810810
int scheme;
811811
char *name;
812812

813-
if (!PyArg_Parse(args, "i", &scheme))
813+
if (!PyArg_ParseTuple(args, "i", &scheme))
814814
return NULL;
815815

816816
name = clGetAlgorithmName(scheme);
@@ -829,9 +829,9 @@ do_set(PyObject *self, PyObject *args, int (*func)(int, int, int))
829829
float fvalue;
830830
int is_float = 0;
831831

832-
if (!PyArg_Parse(args, "(iii)", &scheme, &paramID, &value)) {
832+
if (!PyArg_ParseTuple(args, "iii", &scheme, &paramID, &value)) {
833833
PyErr_Clear();
834-
if (!PyArg_Parse(args, "(iif)", &scheme, &paramID, &fvalue)) {
834+
if (!PyArg_ParseTuple(args, "iif", &scheme, &paramID, &fvalue)) {
835835
PyErr_Clear();
836836
PyErr_SetString(PyExc_TypeError,
837837
"bad argument list (format '(iii)' or '(iif)')");
@@ -884,15 +884,15 @@ cl_SetMax(PyObject *self, PyObject *args)
884884
static PyObject *cl_##name(PyObject *self, PyObject *args) \
885885
{ \
886886
int x; \
887-
if (!PyArg_Parse(args, "i", &x)) return NULL; \
887+
if (!PyArg_ParseTuple(args, "i", &x)) return NULL; \
888888
return Py##handler(CL_##name(x)); \
889889
}
890890

891891
#define func2(name, handler) \
892892
static PyObject *cl_##name(PyObject *self, PyObject *args) \
893893
{ \
894894
int a1, a2; \
895-
if (!PyArg_Parse(args, "(ii)", &a1, &a2)) return NULL; \
895+
if (!PyArg_ParseTuple(args, "ii", &a1, &a2)) return NULL; \
896896
return Py##handler(CL_##name(a1, a2)); \
897897
}
898898

@@ -926,30 +926,30 @@ cvt_type(PyObject *self, PyObject *args)
926926
#endif
927927

928928
static PyMethodDef cl_methods[] = {
929-
{"CompressImage", cl_CompressImage, METH_OLDARGS},
930-
{"DecompressImage", cl_DecompressImage, METH_OLDARGS},
931-
{"GetAlgorithmName", cl_GetAlgorithmName, METH_OLDARGS},
932-
{"OpenCompressor", cl_OpenCompressor, METH_OLDARGS},
933-
{"OpenDecompressor", cl_OpenDecompressor, METH_OLDARGS},
934-
{"QueryAlgorithms", cl_QueryAlgorithms, METH_OLDARGS},
935-
{"QueryMaxHeaderSize", cl_QueryMaxHeaderSize, METH_OLDARGS},
936-
{"QueryScheme", cl_QueryScheme, METH_OLDARGS},
937-
{"QuerySchemeFromName", cl_QuerySchemeFromName, METH_OLDARGS},
938-
{"SetDefault", cl_SetDefault, METH_OLDARGS},
939-
{"SetMax", cl_SetMax, METH_OLDARGS},
940-
{"SetMin", cl_SetMin, METH_OLDARGS},
941-
{"BytesPerSample", cl_BytesPerSample, METH_OLDARGS},
942-
{"BytesPerPixel", cl_BytesPerPixel, METH_OLDARGS},
943-
{"AudioFormatName", cl_AudioFormatName, METH_OLDARGS},
944-
{"VideoFormatName", cl_VideoFormatName, METH_OLDARGS},
945-
{"AlgorithmNumber", cl_AlgorithmNumber, METH_OLDARGS},
946-
{"AlgorithmType", cl_AlgorithmType, METH_OLDARGS},
947-
{"Algorithm", cl_Algorithm, METH_OLDARGS},
948-
{"ParamNumber", cl_ParamNumber, METH_OLDARGS},
949-
{"ParamType", cl_ParamType, METH_OLDARGS},
950-
{"ParamID", cl_ParamID, METH_OLDARGS},
929+
{"CompressImage", cl_CompressImage, METH_VARARGS},
930+
{"DecompressImage", cl_DecompressImage, METH_VARARGS},
931+
{"GetAlgorithmName", cl_GetAlgorithmName, METH_VARARGS},
932+
{"OpenCompressor", cl_OpenCompressor, METH_VARARGS},
933+
{"OpenDecompressor", cl_OpenDecompressor, METH_VARARGS},
934+
{"QueryAlgorithms", cl_QueryAlgorithms, METH_VARARGS},
935+
{"QueryMaxHeaderSize", cl_QueryMaxHeaderSize, METH_VARARGS},
936+
{"QueryScheme", cl_QueryScheme, METH_VARARGS},
937+
{"QuerySchemeFromName", cl_QuerySchemeFromName, METH_VARARGS},
938+
{"SetDefault", cl_SetDefault, METH_VARARGS},
939+
{"SetMax", cl_SetMax, METH_VARARGS},
940+
{"SetMin", cl_SetMin, METH_VARARGS},
941+
{"BytesPerSample", cl_BytesPerSample, METH_VARARGS},
942+
{"BytesPerPixel", cl_BytesPerPixel, METH_VARARGS},
943+
{"AudioFormatName", cl_AudioFormatName, METH_VARARGS},
944+
{"VideoFormatName", cl_VideoFormatName, METH_VARARGS},
945+
{"AlgorithmNumber", cl_AlgorithmNumber, METH_VARARGS},
946+
{"AlgorithmType", cl_AlgorithmType, METH_VARARGS},
947+
{"Algorithm", cl_Algorithm, METH_VARARGS},
948+
{"ParamNumber", cl_ParamNumber, METH_VARARGS},
949+
{"ParamType", cl_ParamType, METH_VARARGS},
950+
{"ParamID", cl_ParamID, METH_VARARGS},
951951
#ifdef CLDEBUG
952-
{"cvt_type", cvt_type, METH_OLDARGS},
952+
{"cvt_type", cvt_type, METH_VARARGS},
953953
#endif
954954
{NULL, NULL} /* Sentinel */
955955
};

Modules/imageop.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ imageop_crop(PyObject *self, PyObject *args)
3535
int ix, iy, xstep, ystep;
3636
PyObject *rv;
3737

38-
if ( !PyArg_Parse(args, "(s#iiiiiii)", &cp, &len, &size, &x, &y,
38+
if ( !PyArg_ParseTuple(args, "s#iiiiiii", &cp, &len, &size, &x, &y,
3939
&newx1, &newy1, &newx2, &newy2) )
4040
return 0;
4141

@@ -90,7 +90,7 @@ imageop_scale(PyObject *self, PyObject *args)
9090
int oix, oiy;
9191
PyObject *rv;
9292

93-
if ( !PyArg_Parse(args, "(s#iiiii)",
93+
if ( !PyArg_ParseTuple(args, "s#iiiii",
9494
&cp, &len, &size, &x, &y, &newx, &newy) )
9595
return 0;
9696

@@ -136,7 +136,7 @@ imageop_tovideo(PyObject *self, PyObject *args)
136136
PyObject *rv;
137137

138138

139-
if ( !PyArg_Parse(args, "(s#iii)", &cp, &len, &width, &maxx, &maxy) )
139+
if ( !PyArg_ParseTuple(args, "s#iii", &cp, &len, &width, &maxx, &maxy) )
140140
return 0;
141141

142142
if ( width != 1 && width != 4 ) {
@@ -190,7 +190,7 @@ imageop_grey2mono(PyObject *self, PyObject *args)
190190
int i, bit;
191191

192192

193-
if ( !PyArg_Parse(args, "(s#iii)", &cp, &len, &x, &y, &tres) )
193+
if ( !PyArg_ParseTuple(args, "s#iii", &cp, &len, &x, &y, &tres) )
194194
return 0;
195195

196196
if ( x*y != len ) {
@@ -231,7 +231,7 @@ imageop_grey2grey4(PyObject *self, PyObject *args)
231231
int pos;
232232

233233

234-
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) )
234+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
235235
return 0;
236236

237237
if ( x*y != len ) {
@@ -270,7 +270,7 @@ imageop_grey2grey2(PyObject *self, PyObject *args)
270270
int pos;
271271

272272

273-
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) )
273+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
274274
return 0;
275275

276276
if ( x*y != len ) {
@@ -308,7 +308,7 @@ imageop_dither2mono(PyObject *self, PyObject *args)
308308
int i, bit;
309309

310310

311-
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) )
311+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
312312
return 0;
313313

314314
if ( x*y != len ) {
@@ -354,7 +354,7 @@ imageop_dither2grey2(PyObject *self, PyObject *args)
354354
int sum = 0, nvalue;
355355

356356

357-
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) )
357+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
358358
return 0;
359359

360360
if ( x*y != len ) {
@@ -393,7 +393,7 @@ imageop_mono2grey(PyObject *self, PyObject *args)
393393
PyObject *rv;
394394
int i, bit;
395395

396-
if ( !PyArg_Parse(args, "(s#iiii)", &cp, &len, &x, &y, &v0, &v1) )
396+
if ( !PyArg_ParseTuple(args, "s#iiii", &cp, &len, &x, &y, &v0, &v1) )
397397
return 0;
398398

399399
nlen = x*y;
@@ -430,7 +430,7 @@ imageop_grey22grey(PyObject *self, PyObject *args)
430430
PyObject *rv;
431431
int i, pos, value = 0, nvalue;
432432

433-
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) )
433+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
434434
return 0;
435435

436436
nlen = x*y;
@@ -466,7 +466,7 @@ imageop_grey42grey(PyObject *self, PyObject *args)
466466
PyObject *rv;
467467
int i, pos, value = 0, nvalue;
468468

469-
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) )
469+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
470470
return 0;
471471

472472
nlen = x*y;
@@ -503,7 +503,7 @@ imageop_rgb2rgb8(PyObject *self, PyObject *args)
503503
int i, r, g, b;
504504
Py_UInt32 value, nvalue;
505505

506-
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) )
506+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
507507
return 0;
508508

509509
nlen = x*y;
@@ -545,7 +545,7 @@ imageop_rgb82rgb(PyObject *self, PyObject *args)
545545
int i, r, g, b;
546546
Py_UInt32 value, nvalue;
547547

548-
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) )
548+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
549549
return 0;
550550

551551
nlen = x*y;
@@ -586,7 +586,7 @@ imageop_rgb2grey(PyObject *self, PyObject *args)
586586
int i, r, g, b;
587587
Py_UInt32 value, nvalue;
588588

589-
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) )
589+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
590590
return 0;
591591

592592
nlen = x*y;
@@ -622,7 +622,7 @@ imageop_grey2rgb(PyObject *self, PyObject *args)
622622
int i;
623623
Py_UInt32 value;
624624

625-
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) )
625+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
626626
return 0;
627627

628628
nlen = x*y;
@@ -677,21 +677,21 @@ imageop_mul(object *self, object *args)
677677
*/
678678

679679
static PyMethodDef imageop_methods[] = {
680-
{ "crop", imageop_crop, METH_OLDARGS },
681-
{ "scale", imageop_scale, METH_OLDARGS },
682-
{ "grey2mono", imageop_grey2mono, METH_OLDARGS },
683-
{ "grey2grey2", imageop_grey2grey2, METH_OLDARGS },
684-
{ "grey2grey4", imageop_grey2grey4, METH_OLDARGS },
685-
{ "dither2mono", imageop_dither2mono, METH_OLDARGS },
686-
{ "dither2grey2", imageop_dither2grey2, METH_OLDARGS },
687-
{ "mono2grey", imageop_mono2grey, METH_OLDARGS },
688-
{ "grey22grey", imageop_grey22grey, METH_OLDARGS },
689-
{ "grey42grey", imageop_grey42grey, METH_OLDARGS },
690-
{ "tovideo", imageop_tovideo, METH_OLDARGS },
691-
{ "rgb2rgb8", imageop_rgb2rgb8, METH_OLDARGS },
692-
{ "rgb82rgb", imageop_rgb82rgb, METH_OLDARGS },
693-
{ "rgb2grey", imageop_rgb2grey, METH_OLDARGS },
694-
{ "grey2rgb", imageop_grey2rgb, METH_OLDARGS },
680+
{ "crop", imageop_crop, METH_VARARGS },
681+
{ "scale", imageop_scale, METH_VARARGS },
682+
{ "grey2mono", imageop_grey2mono, METH_VARARGS },
683+
{ "grey2grey2", imageop_grey2grey2, METH_VARARGS },
684+
{ "grey2grey4", imageop_grey2grey4, METH_VARARGS },
685+
{ "dither2mono", imageop_dither2mono, METH_VARARGS },
686+
{ "dither2grey2", imageop_dither2grey2, METH_VARARGS },
687+
{ "mono2grey", imageop_mono2grey, METH_VARARGS },
688+
{ "grey22grey", imageop_grey22grey, METH_VARARGS },
689+
{ "grey42grey", imageop_grey42grey, METH_VARARGS },
690+
{ "tovideo", imageop_tovideo, METH_VARARGS },
691+
{ "rgb2rgb8", imageop_rgb2rgb8, METH_VARARGS },
692+
{ "rgb82rgb", imageop_rgb82rgb, METH_VARARGS },
693+
{ "rgb2grey", imageop_rgb2grey, METH_VARARGS },
694+
{ "grey2rgb", imageop_grey2rgb, METH_VARARGS },
695695
{ 0, 0 }
696696
};
697697

Modules/sgimodule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ static PyObject *
1111
sgi_nap(PyObject *self, PyObject *args)
1212
{
1313
long ticks;
14-
if (!PyArg_Parse(args, "l", &ticks))
14+
if (!PyArg_ParseTuple(args, "l:nap", &ticks))
1515
return NULL;
1616
Py_BEGIN_ALLOW_THREADS
1717
sginap(ticks);
@@ -30,7 +30,7 @@ sgi__getpty(PyObject *self, PyObject *args)
3030
int nofork;
3131
char *name;
3232
int fildes;
33-
if (!PyArg_Parse(args, "(iii)", &oflag, &mode, &nofork))
33+
if (!PyArg_ParseTuple(args, "iii:_getpty", &oflag, &mode, &nofork))
3434
return NULL;
3535
errno = 0;
3636
name = _getpty(&fildes, oflag, (mode_t)mode, nofork);
@@ -42,8 +42,8 @@ sgi__getpty(PyObject *self, PyObject *args)
4242
}
4343

4444
static PyMethodDef sgi_methods[] = {
45-
{"nap", sgi_nap, METH_OLDARGS},
46-
{"_getpty", sgi__getpty, METH_OLDARGS},
45+
{"nap", sgi_nap, METH_VARARGS},
46+
{"_getpty", sgi__getpty, METH_VARARGS},
4747
{NULL, NULL} /* sentinel */
4848
};
4949

0 commit comments

Comments
 (0)