1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
/* Miscellaneous common routines
* See https://www.python-ldap.org/ for details. */
#include "common.h"
/* dynamically add the methods into the module dictionary d */
void
LDAPadd_methods(PyObject *d, PyMethodDef *methods)
{
PyMethodDef *meth;
for (meth = methods; meth->ml_meth; meth++) {
PyObject *f = PyCFunction_New(meth, NULL);
PyDict_SetItemString(d, meth->ml_name, f);
Py_DECREF(f);
}
}
/* Raise TypeError with custom message and object */
PyObject *
LDAPerror_TypeError(const char *msg, PyObject *obj)
{
PyObject *args = Py_BuildValue("sO", msg, obj);
if (args == NULL) {
return NULL;
}
PyErr_SetObject(PyExc_TypeError, args);
Py_DECREF(args);
return NULL;
}
|