Convert from using METH_OLDARGS to METH_NOARGS. · pythoncapi/cpython@50905b5 · GitHub
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

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

0 commit comments

Comments
 (0)