mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
Please review for correctness.
This commit is contained in:
parent
ba3a16c6c3
commit
b82d34f91e
3 changed files with 34 additions and 47 deletions
|
@ -39,10 +39,8 @@ dl_dealloc(dlobject *xp)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
dl_close(dlobject *xp, PyObject *args)
|
||||
dl_close(dlobject *xp)
|
||||
{
|
||||
if (!PyArg_Parse(args, ""))
|
||||
return NULL;
|
||||
if (xp->dl_handle != NULL) {
|
||||
dlclose(xp->dl_handle);
|
||||
xp->dl_handle = NULL;
|
||||
|
@ -56,8 +54,13 @@ dl_sym(dlobject *xp, PyObject *args)
|
|||
{
|
||||
char *name;
|
||||
PyUnivPtr *func;
|
||||
if (!PyArg_Parse(args, "s", &name))
|
||||
if (PyString_Check(args)) {
|
||||
name = PyString_AS_STRING(args);
|
||||
} else {
|
||||
PyErr_Format(PyExc_TypeError, "expected string, found %.200s",
|
||||
args->ob_type->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
func = dlsym(xp->dl_handle, name);
|
||||
if (func == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
|
@ -121,8 +124,8 @@ dl_call(dlobject *xp, PyObject *args)
|
|||
|
||||
static PyMethodDef dlobject_methods[] = {
|
||||
{"call", (PyCFunction)dl_call, METH_VARARGS},
|
||||
{"sym", (PyCFunction)dl_sym, METH_OLDARGS},
|
||||
{"close", (PyCFunction)dl_close, METH_OLDARGS},
|
||||
{"sym", (PyCFunction)dl_sym, METH_O},
|
||||
{"close", (PyCFunction)dl_close, METH_NOARGS},
|
||||
{NULL, NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
@ -165,11 +168,11 @@ dl_open(PyObject *self, PyObject *args)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (PyArg_Parse(args, "z", &name))
|
||||
if (PyArg_ParseTuple(args, "z:open", &name))
|
||||
mode = RTLD_LAZY;
|
||||
else {
|
||||
PyErr_Clear();
|
||||
if (!PyArg_Parse(args, "(zi)", &name, &mode))
|
||||
if (!PyArg_ParseTuple(args, "zi:open", &name, &mode))
|
||||
return NULL;
|
||||
#ifndef RTLD_NOW
|
||||
if (mode != RTLD_LAZY) {
|
||||
|
@ -187,7 +190,7 @@ dl_open(PyObject *self, PyObject *args)
|
|||
}
|
||||
|
||||
static PyMethodDef dl_methods[] = {
|
||||
{"open", dl_open, METH_OLDARGS},
|
||||
{"open", dl_open, METH_VARARGS},
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue