diff options
Diffstat (limited to 'Modules/dlmodule.c')
-rw-r--r-- | Modules/dlmodule.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/Modules/dlmodule.c b/Modules/dlmodule.c index d2364d4..4606ea8 100644 --- a/Modules/dlmodule.c +++ b/Modules/dlmodule.c @@ -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 */ }; |