Skip to content

Commit bf92f46

Browse files
committed
Convert more modules to METH_VARARGS.
1 parent 96a8c39 commit bf92f46

8 files changed

Lines changed: 139 additions & 113 deletions

File tree

Mac/Modules/gestaltmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ gestalt_gestalt(PyObject *self, PyObject *args)
3535
OSErr iErr;
3636
OSType selector;
3737
long response;
38-
if (!PyArg_Parse(args, "O&", PyMac_GetOSType, &selector))
38+
if (!PyArg_ParseTuple(args, "O&", PyMac_GetOSType, &selector))
3939
return NULL;
4040
iErr = Gestalt ( selector, &response );
4141
if (iErr != 0)
@@ -44,7 +44,7 @@ gestalt_gestalt(PyObject *self, PyObject *args)
4444
}
4545

4646
static struct PyMethodDef gestalt_methods[] = {
47-
{"gestalt", gestalt_gestalt},
47+
{"gestalt", gestalt_gestalt, METH_VARARGS},
4848
{NULL, NULL} /* Sentinel */
4949
};
5050

Modules/flmodule.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,22 +148,21 @@ releaseobjects(FL_FORM *form)
148148
static PyObject *
149149
generic_set_call_back(genericobject *g, PyObject *args)
150150
{
151-
if (args == NULL) {
151+
if (PyTuple_GET_SIZE(args) == 0) {
152152
Py_XDECREF(g->ob_callback);
153153
Py_XDECREF(g->ob_callback_arg);
154154
g->ob_callback = NULL;
155155
g->ob_callback_arg = NULL;
156156
}
157157
else {
158-
if (!PyTuple_Check(args) || PyTuple_Size(args) != 2) {
159-
PyErr_BadArgument();
160-
return NULL;
161-
}
158+
PyObject *a, *b;
159+
if (!PyArg_UnpackTuple(args, "set_call_back", 2, 2, &a, &b)
160+
return NULL;
162161
Py_XDECREF(g->ob_callback);
163162
Py_XDECREF(g->ob_callback_arg);
164-
g->ob_callback = PyTuple_GetItem(args, 0);
163+
g->ob_callback = a;
165164
Py_INCREF(g->ob_callback);
166-
g->ob_callback_arg = PyTuple_GetItem(args, 1);
165+
g->ob_callback_arg = b;
167166
Py_INCREF(g->ob_callback_arg);
168167
}
169168
Py_INCREF(Py_None);
@@ -250,7 +249,7 @@ generic_set_object_shortcut(genericobject *g, PyObject *args)
250249
}
251250

252251
static PyMethodDef generic_methods[] = {
253-
{"set_call_back", (PyCFunction)generic_set_call_back, METH_OLDARGS},
252+
{"set_call_back", (PyCFunction)generic_set_call_back, METH_VARARGS},
254253
{"delete_object", (PyCFunction)generic_delete_object, METH_NOARGS},
255254
{"show_object", (PyCFunction)generic_show_object, METH_NOARGS},
256255
{"hide_object", (PyCFunction)generic_hide_object, METH_NOARGS},
@@ -261,7 +260,7 @@ static PyMethodDef generic_methods[] = {
261260
#endif
262261
{"activate_object", (PyCFunction)generic_activate_object, METH_NOARGS},
263262
{"deactivate_object", (PyCFunction)generic_deactivate_object, METH_NOARGS},
264-
{"set_object_shortcut", (PyCFunction)generic_set_object_shortcut, METH_OLDARGS},
263+
{"set_object_shortcut", (PyCFunction)generic_set_object_shortcut, METH_VARARGS},
265264
{NULL, NULL} /* sentinel */
266265
};
267266

Modules/mathmodule.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,8 @@ PyDoc_STRVAR(math_log_doc,
277277
If the base not specified, returns the natural logarithm (base e) of x.");
278278

279279
static PyObject *
280-
math_log10(PyObject *self, PyObject *args)
280+
math_log10(PyObject *self, PyObject *arg)
281281
{
282-
PyObject *arg;
283-
284-
if (!PyArg_UnpackTuple(args, "log10", 1, 1, &arg))
285-
return NULL;
286282
return loghelper(args, log10, "d:log10", arg);
287283
}
288284

@@ -332,7 +328,7 @@ static PyMethodDef math_methods[] = {
332328
{"hypot", math_hypot, METH_VARARGS, math_hypot_doc},
333329
{"ldexp", math_ldexp, METH_VARARGS, math_ldexp_doc},
334330
{"log", math_log, METH_VARARGS, math_log_doc},
335-
{"log10", math_log10, METH_VARARGS, math_log10_doc},
331+
{"log10", math_log10, METH_O, math_log10_doc},
336332
{"modf", math_modf, METH_VARARGS, math_modf_doc},
337333
{"pow", math_pow, METH_VARARGS, math_pow_doc},
338334
{"radians", math_radians, METH_VARARGS, math_radians_doc},

PC/_subprocess.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ sp_handle_dealloc(sp_handle_object* self)
108108
}
109109

110110
static PyMethodDef sp_handle_methods[] = {
111-
{"Detach", (PyCFunction) sp_handle_detach, 1},
112-
{"Close", (PyCFunction) sp_handle_close, 1},
111+
{"Detach", (PyCFunction) sp_handle_detach, METH_VARARGS},
112+
{"Close", (PyCFunction) sp_handle_close, METH_VARARGS},
113113
{NULL, NULL}
114114
};
115115

PC/example_nt/example.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ex_foo(PyObject *self, PyObject *args)
99
}
1010

1111
static PyMethodDef example_methods[] = {
12-
{"foo", ex_foo, 1, "foo() doc string"},
12+
{"foo", ex_foo, METH_VARARGS, "foo() doc string"},
1313
{NULL, NULL}
1414
};
1515

Python/marshal.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,12 +1073,10 @@ marshal_dump(PyObject *self, PyObject *args)
10731073
}
10741074

10751075
static PyObject *
1076-
marshal_load(PyObject *self, PyObject *args)
1076+
marshal_load(PyObject *self, PyObject *f)
10771077
{
10781078
RFILE rf;
1079-
PyObject *f, *result;
1080-
if (!PyArg_ParseTuple(args, "O:load", &f))
1081-
return NULL;
1079+
PyObject *result;
10821080
if (!PyFile_Check(f)) {
10831081
PyErr_SetString(PyExc_TypeError,
10841082
"marshal.load() arg must be file");
@@ -1121,7 +1119,7 @@ marshal_loads(PyObject *self, PyObject *args)
11211119

11221120
static PyMethodDef marshal_methods[] = {
11231121
{"dump", marshal_dump, METH_VARARGS},
1124-
{"load", marshal_load, METH_VARARGS},
1122+
{"load", marshal_load, METH_O},
11251123
{"dumps", marshal_dumps, METH_VARARGS},
11261124
{"loads", marshal_loads, METH_VARARGS},
11271125
{NULL, NULL} /* sentinel */

0 commit comments

Comments
 (0)