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

Skip to content

Commit 08ea61a

Browse files
committed
Remove PyArg_ParseTuple() for methods which take no args,
use METH_NOARGS instead
1 parent e241ce8 commit 08ea61a

1 file changed

Lines changed: 13 additions & 23 deletions

File tree

Python/import.c

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,8 @@ unlock_import(void)
286286
#endif
287287

288288
static PyObject *
289-
imp_lock_held(PyObject *self, PyObject *args)
289+
imp_lock_held(PyObject *self, PyObject *noargs)
290290
{
291-
if (!PyArg_ParseTuple(args, ":lock_held"))
292-
return NULL;
293291
#ifdef WITH_THREAD
294292
return PyBool_FromLong(import_lock_thread != -1);
295293
#else
@@ -298,10 +296,8 @@ imp_lock_held(PyObject *self, PyObject *args)
298296
}
299297

300298
static PyObject *
301-
imp_acquire_lock(PyObject *self, PyObject *args)
299+
imp_acquire_lock(PyObject *self, PyObject *noargs)
302300
{
303-
if (!PyArg_ParseTuple(args, ":acquire_lock"))
304-
return NULL;
305301
#ifdef WITH_THREAD
306302
lock_import();
307303
#endif
@@ -310,10 +306,8 @@ imp_acquire_lock(PyObject *self, PyObject *args)
310306
}
311307

312308
static PyObject *
313-
imp_release_lock(PyObject *self, PyObject *args)
309+
imp_release_lock(PyObject *self, PyObject *noargs)
314310
{
315-
if (!PyArg_ParseTuple(args, ":release_lock"))
316-
return NULL;
317311
#ifdef WITH_THREAD
318312
if (unlock_import() < 0) {
319313
PyErr_SetString(PyExc_RuntimeError,
@@ -2428,12 +2422,10 @@ PyImport_Import(PyObject *module_name)
24282422
*/
24292423

24302424
static PyObject *
2431-
imp_get_magic(PyObject *self, PyObject *args)
2425+
imp_get_magic(PyObject *self, PyObject *noargs)
24322426
{
24332427
char buf[4];
24342428

2435-
if (!PyArg_ParseTuple(args, ":get_magic"))
2436-
return NULL;
24372429
buf[0] = (char) ((pyc_magic >> 0) & 0xff);
24382430
buf[1] = (char) ((pyc_magic >> 8) & 0xff);
24392431
buf[2] = (char) ((pyc_magic >> 16) & 0xff);
@@ -2443,13 +2435,11 @@ imp_get_magic(PyObject *self, PyObject *args)
24432435
}
24442436

24452437
static PyObject *
2446-
imp_get_suffixes(PyObject *self, PyObject *args)
2438+
imp_get_suffixes(PyObject *self, PyObject *noargs)
24472439
{
24482440
PyObject *list;
24492441
struct filedescr *fdp;
24502442

2451-
if (!PyArg_ParseTuple(args, ":get_suffixes"))
2452-
return NULL;
24532443
list = PyList_New(0);
24542444
if (list == NULL)
24552445
return NULL;
@@ -2791,14 +2781,14 @@ Release the interpreter's import lock.\n\
27912781
On platforms without threads, this function does nothing.");
27922782

27932783
static PyMethodDef imp_methods[] = {
2794-
{"find_module", imp_find_module, METH_VARARGS, doc_find_module},
2795-
{"get_magic", imp_get_magic, METH_VARARGS, doc_get_magic},
2796-
{"get_suffixes", imp_get_suffixes, METH_VARARGS, doc_get_suffixes},
2797-
{"load_module", imp_load_module, METH_VARARGS, doc_load_module},
2798-
{"new_module", imp_new_module, METH_VARARGS, doc_new_module},
2799-
{"lock_held", imp_lock_held, METH_VARARGS, doc_lock_held},
2800-
{"acquire_lock", imp_acquire_lock, METH_VARARGS, doc_acquire_lock},
2801-
{"release_lock", imp_release_lock, METH_VARARGS, doc_release_lock},
2784+
{"find_module", imp_find_module, METH_VARARGS, doc_find_module},
2785+
{"get_magic", imp_get_magic, METH_NOARGS, doc_get_magic},
2786+
{"get_suffixes", imp_get_suffixes, METH_NOARGS, doc_get_suffixes},
2787+
{"load_module", imp_load_module, METH_VARARGS, doc_load_module},
2788+
{"new_module", imp_new_module, METH_VARARGS, doc_new_module},
2789+
{"lock_held", imp_lock_held, METH_NOARGS, doc_lock_held},
2790+
{"acquire_lock", imp_acquire_lock, METH_NOARGS, doc_acquire_lock},
2791+
{"release_lock", imp_release_lock, METH_NOARGS, doc_release_lock},
28022792
/* The rest are obsolete */
28032793
{"get_frozen_object", imp_get_frozen_object, METH_VARARGS},
28042794
{"init_builtin", imp_init_builtin, METH_VARARGS},

0 commit comments

Comments
 (0)