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

Skip to content

Commit 50905b5

Browse files
committed
Convert from using METH_OLDARGS to METH_NOARGS.
These should be safe.
1 parent 01b2694 commit 50905b5

3 files changed

Lines changed: 44 additions & 85 deletions

File tree

Modules/clmodule.c

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,10 @@ cl_DecompressImage(PyObject *self, PyObject *args)
183183
}
184184

185185
static PyObject *
186-
doClose(clobject *self, PyObject *args, int (*close_func)(CL_Handle))
186+
doClose(clobject *self, int (*close_func)(CL_Handle))
187187
{
188188
CheckCompressor(self);
189189

190-
if (!PyArg_NoArgs(args))
191-
return NULL;
192-
193190
error_handler_called = 0;
194191
if ((*close_func)(self->ob_compressorHdl) == FAILURE ||
195192
error_handler_called) {
@@ -209,15 +206,15 @@ doClose(clobject *self, PyObject *args, int (*close_func)(CL_Handle))
209206
}
210207

211208
static PyObject *
212-
clm_CloseCompressor(PyObject *self, PyObject *args)
209+
clm_CloseCompressor(PyObject *self)
213210
{
214-
return doClose(SELF, args, clCloseCompressor);
211+
return doClose(SELF, clCloseCompressor);
215212
}
216213

217214
static PyObject *
218-
clm_CloseDecompressor(PyObject *self, PyObject *args)
215+
clm_CloseDecompressor(PyObject *self)
219216
{
220-
return doClose(SELF, args, clCloseDecompressor);
217+
return doClose(SELF, clCloseDecompressor);
221218
}
222219

223220
static PyObject *
@@ -479,7 +476,7 @@ clm_GetParamID(PyObject *self, PyObject *args)
479476
}
480477

481478
static PyObject *
482-
clm_QueryParams(PyObject *self, PyObject *args)
479+
clm_QueryParams(PyObject *self)
483480
{
484481
int bufferlength;
485482
int *PVbuffer;
@@ -488,9 +485,6 @@ clm_QueryParams(PyObject *self, PyObject *args)
488485

489486
CheckCompressor(SELF);
490487

491-
if (!PyArg_NoArgs(args))
492-
return NULL;
493-
494488
error_handler_called = 0;
495489
bufferlength = clQueryParams(SELF->ob_compressorHdl, 0, 0);
496490
if (error_handler_called)
@@ -574,13 +568,9 @@ clm_GetName(PyObject *self, PyObject *args)
574568
}
575569

576570
static PyObject *
577-
clm_QuerySchemeFromHandle(PyObject *self, PyObject *args)
571+
clm_QuerySchemeFromHandle(PyObject *self)
578572
{
579573
CheckCompressor(SELF);
580-
581-
if (!PyArg_NoArgs(args))
582-
return NULL;
583-
584574
return PyInt_FromLong(clQuerySchemeFromHandle(SELF->ob_compressorHdl));
585575
}
586576

@@ -600,25 +590,25 @@ clm_ReadHeader(PyObject *self, PyObject *args)
600590
}
601591

602592
static PyMethodDef compressor_methods[] = {
603-
{"close", clm_CloseCompressor, METH_OLDARGS}, /* alias */
604-
{"CloseCompressor", clm_CloseCompressor, METH_OLDARGS},
593+
{"close", clm_CloseCompressor, METH_NOARGS}, /* alias */
594+
{"CloseCompressor", clm_CloseCompressor, METH_NOARGS},
605595
{"Compress", clm_Compress, METH_OLDARGS},
606596
{"GetDefault", clm_GetDefault, METH_OLDARGS},
607597
{"GetMinMax", clm_GetMinMax, METH_OLDARGS},
608598
{"GetName", clm_GetName, METH_OLDARGS},
609599
{"GetParam", clm_GetParam, METH_OLDARGS},
610600
{"GetParamID", clm_GetParamID, METH_OLDARGS},
611601
{"GetParams", clm_GetParams, METH_OLDARGS},
612-
{"QueryParams", clm_QueryParams, METH_OLDARGS},
613-
{"QuerySchemeFromHandle",clm_QuerySchemeFromHandle, METH_OLDARGS},
602+
{"QueryParams", clm_QueryParams, METH_NOARGS},
603+
{"QuerySchemeFromHandle",clm_QuerySchemeFromHandle, METH_NOARGS},
614604
{"SetParam", clm_SetParam, METH_OLDARGS},
615605
{"SetParams", clm_SetParams, METH_OLDARGS},
616606
{NULL, NULL} /* sentinel */
617607
};
618608

619609
static PyMethodDef decompressor_methods[] = {
620-
{"close", clm_CloseDecompressor, METH_OLDARGS}, /* alias */
621-
{"CloseDecompressor", clm_CloseDecompressor, METH_OLDARGS},
610+
{"close", clm_CloseDecompressor, METH_NOARGS}, /* alias */
611+
{"CloseDecompressor", clm_CloseDecompressor, METH_NOARGS},
622612
{"Decompress", clm_Decompress, METH_OLDARGS},
623613
{"GetDefault", clm_GetDefault, METH_OLDARGS},
624614
{"GetMinMax", clm_GetMinMax, METH_OLDARGS},
@@ -627,8 +617,8 @@ static PyMethodDef decompressor_methods[] = {
627617
{"GetParamID", clm_GetParamID, METH_OLDARGS},
628618
{"GetParams", clm_GetParams, METH_OLDARGS},
629619
{"ReadHeader", clm_ReadHeader, METH_OLDARGS},
630-
{"QueryParams", clm_QueryParams, METH_OLDARGS},
631-
{"QuerySchemeFromHandle",clm_QuerySchemeFromHandle, METH_OLDARGS},
620+
{"QueryParams", clm_QueryParams, METH_NOARGS},
621+
{"QuerySchemeFromHandle",clm_QuerySchemeFromHandle, METH_NOARGS},
632622
{"SetParam", clm_SetParam, METH_OLDARGS},
633623
{"SetParams", clm_SetParams, METH_OLDARGS},
634624
{NULL, NULL} /* sentinel */

Modules/fmmodule.c

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,18 @@ fh_scalefont(fhobject *self, PyObject *args)
4949
/* XXX fmmakefont */
5050

5151
static PyObject *
52-
fh_setfont(fhobject *self, PyObject *args)
52+
fh_setfont(fhobject *self)
5353
{
54-
if (!PyArg_NoArgs(args))
55-
return NULL;
5654
fmsetfont(self->fh_fh);
5755
Py_INCREF(Py_None);
5856
return Py_None;
5957
}
6058

6159
static PyObject *
62-
fh_getfontname(fhobject *self, PyObject *args)
60+
fh_getfontname(fhobject *self)
6361
{
6462
char fontname[256];
6563
int len;
66-
if (!PyArg_NoArgs(args))
67-
return NULL;
6864
len = fmgetfontname(self->fh_fh, sizeof fontname, fontname);
6965
if (len < 0) {
7066
PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontname");
@@ -74,12 +70,10 @@ fh_getfontname(fhobject *self, PyObject *args)
7470
}
7571

7672
static PyObject *
77-
fh_getcomment(fhobject *self, PyObject *args)
73+
fh_getcomment(fhobject *self)
7874
{
7975
char comment[256];
8076
int len;
81-
if (!PyArg_NoArgs(args))
82-
return NULL;
8377
len = fmgetcomment(self->fh_fh, sizeof comment, comment);
8478
if (len < 0) {
8579
PyErr_SetString(PyExc_RuntimeError, "error in fmgetcomment");
@@ -89,11 +83,9 @@ fh_getcomment(fhobject *self, PyObject *args)
8983
}
9084

9185
static PyObject *
92-
fh_getfontinfo(fhobject *self, PyObject *args)
86+
fh_getfontinfo(fhobject *self)
9387
{
9488
fmfontinfo info;
95-
if (!PyArg_NoArgs(args))
96-
return NULL;
9789
if (fmgetfontinfo(self->fh_fh, &info) < 0) {
9890
PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontinfo");
9991
return NULL;
@@ -126,11 +118,11 @@ fh_getstrwidth(fhobject *self, PyObject *args)
126118
}
127119

128120
static PyMethodDef fh_methods[] = {
129-
{"scalefont", (PyCFunction)fh_scalefont, METH_OLDARGS},
130-
{"setfont", (PyCFunction)fh_setfont, METH_OLDARGS},
131-
{"getfontname", (PyCFunction)fh_getfontname, METH_OLDARGS},
132-
{"getcomment", (PyCFunction)fh_getcomment, METH_OLDARGS},
133-
{"getfontinfo", (PyCFunction)fh_getfontinfo, METH_OLDARGS},
121+
{"scalefont", (PyCFunction)fh_scalefont, METH_OLDARGS},
122+
{"setfont", (PyCFunction)fh_setfont, METH_NOARGS},
123+
{"getfontname", (PyCFunction)fh_getfontname, METH_NOARGS},
124+
{"getcomment", (PyCFunction)fh_getcomment, METH_NOARGS},
125+
{"getfontinfo", (PyCFunction)fh_getfontinfo, METH_NOARGS},
134126
#if 0
135127
{"getwholemetrics", (PyCFunction)fh_getwholemetrics, METH_OLDARGS},
136128
#endif
@@ -170,10 +162,8 @@ static PyTypeObject Fhtype = {
170162
/* Font Manager functions */
171163

172164
static PyObject *
173-
fm_init(PyObject *self, PyObject *args)
165+
fm_init(PyObject *self)
174166
{
175-
if (!PyArg_NoArgs(args))
176-
return NULL;
177167
fminit();
178168
Py_INCREF(Py_None);
179169
return Py_None;
@@ -224,11 +214,9 @@ clientproc(char *fontname)
224214
}
225215

226216
static PyObject *
227-
fm_enumerate(PyObject *self, PyObject *args)
217+
fm_enumerate(PyObject *self)
228218
{
229219
PyObject *res;
230-
if (!PyArg_NoArgs(args))
231-
return NULL;
232220
fontlist = PyList_New(0);
233221
if (fontlist == NULL)
234222
return NULL;
@@ -250,20 +238,18 @@ fm_setpath(PyObject *self, PyObject *args)
250238
}
251239

252240
static PyObject *
253-
fm_fontpath(PyObject *self, PyObject *args)
241+
fm_fontpath(PyObject *self)
254242
{
255-
if (!PyArg_NoArgs(args))
256-
return NULL;
257243
return PyString_FromString(fmfontpath());
258244
}
259245

260246
static PyMethodDef fm_methods[] = {
261-
{"init", fm_init, METH_OLDARGS},
262-
{"findfont", fm_findfont, METH_OLDARGS},
263-
{"enumerate", fm_enumerate, METH_OLDARGS},
264-
{"prstr", fm_prstr, METH_OLDARGS},
265-
{"setpath", fm_setpath, METH_OLDARGS},
266-
{"fontpath", fm_fontpath, METH_OLDARGS},
247+
{"init", fm_init, METH_NOARGS},
248+
{"findfont", fm_findfont, METH_OLDARGS},
249+
{"enumerate", fm_enumerate, METH_NOARGS},
250+
{"prstr", fm_prstr, METH_OLDARGS},
251+
{"setpath", fm_setpath, METH_OLDARGS},
252+
{"fontpath", fm_fontpath, METH_NOARGS},
267253
{NULL, NULL} /* sentinel */
268254
};
269255

Modules/timingmodule.c

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,63 +8,46 @@
88
#include "timing.h"
99

1010
static PyObject *
11-
start_timing(PyObject *self, PyObject *args)
11+
start_timing(PyObject *self)
1212
{
13-
if (!PyArg_Parse(args, ""))
14-
return NULL;
15-
1613
Py_INCREF(Py_None);
1714
BEGINTIMING;
1815
return Py_None;
1916
}
2017

2118
static PyObject *
22-
finish_timing(PyObject *self, PyObject *args)
19+
finish_timing(PyObject *self)
2320
{
24-
if (!PyArg_Parse(args, ""))
25-
return NULL;
26-
2721
ENDTIMING
2822
Py_INCREF(Py_None);
2923
return Py_None;
3024
}
3125

3226
static PyObject *
33-
seconds(PyObject *self, PyObject *args)
27+
seconds(PyObject *self)
3428
{
35-
if (!PyArg_Parse(args, ""))
36-
return NULL;
37-
3829
return PyInt_FromLong(TIMINGS);
39-
4030
}
4131

4232
static PyObject *
43-
milli(PyObject *self, PyObject *args)
33+
milli(PyObject *self)
4434
{
45-
if (!PyArg_Parse(args, ""))
46-
return NULL;
47-
4835
return PyInt_FromLong(TIMINGMS);
49-
5036
}
37+
5138
static PyObject *
52-
micro(PyObject *self, PyObject *args)
39+
micro(PyObject *self)
5340
{
54-
if (!PyArg_Parse(args, ""))
55-
return NULL;
56-
5741
return PyInt_FromLong(TIMINGUS);
58-
5942
}
6043

6144

6245
static PyMethodDef timing_methods[] = {
63-
{"start", start_timing, METH_OLDARGS},
64-
{"finish", finish_timing, METH_OLDARGS},
65-
{"seconds", seconds, METH_OLDARGS},
66-
{"milli", milli, METH_OLDARGS},
67-
{"micro", micro, METH_OLDARGS},
46+
{"start", (PyCFunction)start_timing, METH_NOARGS},
47+
{"finish", (PyCFunction)finish_timing, METH_NOARGS},
48+
{"seconds", (PyCFunction)seconds, METH_NOARGS},
49+
{"milli", (PyCFunction)milli, METH_NOARGS},
50+
{"micro", (PyCFunction)micro, METH_NOARGS},
6851
{NULL, NULL}
6952
};
7053

0 commit comments

Comments
 (0)