#include "pyldb.h"
#include "dlinklist.h"
+/* discard signature of 'func' in favour of 'target_sig' */
+#define PY_DISCARD_FUNC_SIG(target_sig, func) (target_sig)(void(*)(void))func
+
struct py_ldb_search_iterator_reply;
typedef struct {
static PyTypeObject PyLdbBytesType;
#if PY_MAJOR_VERSION >= 3
-#define PyStr_Check PyUnicode_Check
-#define PyStr_FromString PyUnicode_FromString
#define PyStr_FromStringAndSize PyUnicode_FromStringAndSize
#define PyStr_FromFormat PyUnicode_FromFormat
#define PyStr_FromFormatV PyUnicode_FromFormatV
return result;
}
#else
-#define PyStr_Check PyString_Check
-#define PyStr_FromString PyString_FromString
#define PyStr_FromStringAndSize PyString_FromStringAndSize
#define PyStr_FromFormat PyString_FromFormat
#define PyStr_FromFormatV PyString_FromFormatV
PyErr_NoMemory();
return NULL;
}
- return PyStr_FromString(control);
+ return PyUnicode_FromString(control);
} else {
- return PyStr_FromString("ldb control");
+ return PyUnicode_FromString("ldb control");
}
}
return inst;
}
-static PyObject *py_ldb_control_get_oid(PyLdbControlObject *self)
+static PyObject *py_ldb_control_get_oid(PyLdbControlObject *self,
+ PyObject *Py_UNUSED(ignored))
{
- return PyStr_FromString(self->data->oid);
+ return PyUnicode_FromString(self->data->oid);
}
-static PyObject *py_ldb_control_get_critical(PyLdbControlObject *self)
+static PyObject *py_ldb_control_get_critical(PyLdbControlObject *self,
+ PyObject *Py_UNUSED(ignored))
{
return PyBool_FromLong(self->data->critical);
}
-static PyObject *py_ldb_control_set_critical(PyLdbControlObject *self, PyObject *value, void *closure)
+static int py_ldb_control_set_critical(PyLdbControlObject *self, PyObject *value, void *closure)
{
if (PyObject_IsTrue(value)) {
self->data->critical = true;
}
for (i = 0;result->refs && result->refs[i]; i++) {
- PyList_SetItem(referals, i, PyStr_FromString(result->refs[i]));
+ PyList_SetItem(referals, i, PyUnicode_FromString(result->refs[i]));
}
ret->referals = referals;
return (PyObject *)ret;
return res;
}
-static PyObject *py_ldb_dn_validate(PyLdbDnObject *self)
+static PyObject *py_ldb_dn_validate(PyLdbDnObject *self,
+ PyObject *Py_UNUSED(ignored))
{
return PyBool_FromLong(ldb_dn_validate(self->dn));
}
-static PyObject *py_ldb_dn_is_valid(PyLdbDnObject *self)
+static PyObject *py_ldb_dn_is_valid(PyLdbDnObject *self,
+ PyObject *Py_UNUSED(ignored))
{
return PyBool_FromLong(ldb_dn_is_valid(self->dn));
}
-static PyObject *py_ldb_dn_is_special(PyLdbDnObject *self)
+static PyObject *py_ldb_dn_is_special(PyLdbDnObject *self,
+ PyObject *Py_UNUSED(ignored))
{
return PyBool_FromLong(ldb_dn_is_special(self->dn));
}
-static PyObject *py_ldb_dn_is_null(PyLdbDnObject *self)
+static PyObject *py_ldb_dn_is_null(PyLdbDnObject *self,
+ PyObject *Py_UNUSED(ignored))
{
return PyBool_FromLong(ldb_dn_is_null(self->dn));
}
-static PyObject *py_ldb_dn_get_casefold(PyLdbDnObject *self)
+static PyObject *py_ldb_dn_get_casefold(PyLdbDnObject *self,
+ PyObject *Py_UNUSED(ignored))
{
- return PyStr_FromString(ldb_dn_get_casefold(self->dn));
+ return PyUnicode_FromString(ldb_dn_get_casefold(self->dn));
}
static PyObject *py_ldb_dn_get_linearized(PyLdbDnObject *self)
{
- return PyStr_FromString(ldb_dn_get_linearized(self->dn));
+ return PyUnicode_FromString(ldb_dn_get_linearized(self->dn));
}
-static PyObject *py_ldb_dn_canonical_str(PyLdbDnObject *self)
+static PyObject *py_ldb_dn_canonical_str(PyLdbDnObject *self,
+ PyObject *Py_UNUSED(ignored))
{
- return PyStr_FromString(ldb_dn_canonical_string(self->dn, self->dn));
+ return PyUnicode_FromString(ldb_dn_canonical_string(self->dn, self->dn));
}
-static PyObject *py_ldb_dn_canonical_ex_str(PyLdbDnObject *self)
+static PyObject *py_ldb_dn_canonical_ex_str(PyLdbDnObject *self,
+ PyObject *Py_UNUSED(ignored))
{
- return PyStr_FromString(ldb_dn_canonical_ex_string(self->dn, self->dn));
+ return PyUnicode_FromString(ldb_dn_canonical_ex_string(self->dn, self->dn));
}
static PyObject *py_ldb_dn_extended_str(PyLdbDnObject *self, PyObject *args, PyObject *kwargs)
discard_const_p(char *, kwnames),
&mode))
return NULL;
- return PyStr_FromString(ldb_dn_get_extended_linearized(self->dn, self->dn, mode));
+ return PyUnicode_FromString(ldb_dn_get_extended_linearized(self->dn, self->dn, mode));
}
static PyObject *py_ldb_dn_get_extended_component(PyLdbDnObject *self, PyObject *args)
static PyObject *py_ldb_dn_repr(PyLdbDnObject *self)
{
- PyObject *str = PyStr_FromString(ldb_dn_get_linearized(self->dn));
+ PyObject *str = PyUnicode_FromString(ldb_dn_get_linearized(self->dn));
PyObject *repr, *result;
if (str == NULL)
return NULL;
return richcmp(ret, op);
}
-static PyObject *py_ldb_dn_get_parent(PyLdbDnObject *self)
+static PyObject *py_ldb_dn_get_parent(PyLdbDnObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct ldb_dn *dn = pyldb_Dn_AsDn((PyObject *)self);
struct ldb_dn *parent;
Py_RETURN_NONE;
}
- return PyStr_FromString(name);
+ return PyUnicode_FromString(name);
}
static PyObject *py_ldb_dn_get_component_value(PyLdbDnObject *self, PyObject *args)
Py_RETURN_NONE;
}
-static PyObject *py_ldb_dn_get_rdn_name(PyLdbDnObject *self)
+static PyObject *py_ldb_dn_get_rdn_name(PyLdbDnObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct ldb_dn *dn;
const char *name;
Py_RETURN_NONE;
}
- return PyStr_FromString(name);
+ return PyUnicode_FromString(name);
}
-static PyObject *py_ldb_dn_get_rdn_value(PyLdbDnObject *self)
+static PyObject *py_ldb_dn_get_rdn_value(PyLdbDnObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct ldb_dn *dn;
const struct ldb_val *val;
"Check whether this is a null DN." },
{ "get_casefold", (PyCFunction)py_ldb_dn_get_casefold, METH_NOARGS,
NULL },
- { "get_linearized", (PyCFunction)py_ldb_dn_get_linearized, METH_NOARGS,
+ { "get_linearized", PY_DISCARD_FUNC_SIG(PyCFunction,
+ py_ldb_dn_get_linearized),
+ METH_NOARGS,
NULL },
{ "canonical_str", (PyCFunction)py_ldb_dn_canonical_str, METH_NOARGS,
"S.canonical_str() -> string\n"
{ "canonical_ex_str", (PyCFunction)py_ldb_dn_canonical_ex_str, METH_NOARGS,
"S.canonical_ex_str() -> string\n"
"Canonical version of this DN (like a posix path, with terminating newline)." },
- { "extended_str", (PyCFunction)py_ldb_dn_extended_str, METH_VARARGS | METH_KEYWORDS,
+ { "extended_str", PY_DISCARD_FUNC_SIG(PyCFunction,
+ py_ldb_dn_extended_str),
+ METH_VARARGS | METH_KEYWORDS,
"S.extended_str(mode=1) -> string\n"
"Extended version of this DN" },
{ "parent", (PyCFunction)py_ldb_dn_get_parent, METH_NOARGS,
Py_RETURN_NONE;
}
-static PyObject *py_ldb_transaction_start(PyLdbObject *self)
+static PyObject *py_ldb_transaction_start(PyLdbObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct ldb_context *ldb_ctx = pyldb_Ldb_AsLdbContext(self);
int ldb_err;
Py_RETURN_NONE;
}
-static PyObject *py_ldb_transaction_commit(PyLdbObject *self)
+static PyObject *py_ldb_transaction_commit(PyLdbObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct ldb_context *ldb_ctx = pyldb_Ldb_AsLdbContext(self);
int ldb_err;
Py_RETURN_NONE;
}
-static PyObject *py_ldb_transaction_prepare_commit(PyLdbObject *self)
+static PyObject *py_ldb_transaction_prepare_commit(PyLdbObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct ldb_context *ldb_ctx = pyldb_Ldb_AsLdbContext(self);
int ldb_err;
Py_RETURN_NONE;
}
-static PyObject *py_ldb_transaction_cancel(PyLdbObject *self)
+static PyObject *py_ldb_transaction_cancel(PyLdbObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct ldb_context *ldb_ctx = pyldb_Ldb_AsLdbContext(self);
int ldb_err;
Py_RETURN_NONE;
}
-static PyObject *py_ldb_setup_wellknown_attributes(PyLdbObject *self)
+static PyObject *py_ldb_setup_wellknown_attributes(PyLdbObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct ldb_context *ldb_ctx = pyldb_Ldb_AsLdbContext(self);
int ldb_err;
static PyObject *py_ldb_repr(PyLdbObject *self)
{
- return PyStr_FromString("<ldb connection>");
+ return PyUnicode_FromString("<ldb connection>");
}
-static PyObject *py_ldb_get_root_basedn(PyLdbObject *self)
+static PyObject *py_ldb_get_root_basedn(PyLdbObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct ldb_dn *dn = ldb_get_root_basedn(pyldb_Ldb_AsLdbContext(self));
if (dn == NULL)
}
-static PyObject *py_ldb_get_schema_basedn(PyLdbObject *self)
+static PyObject *py_ldb_get_schema_basedn(PyLdbObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct ldb_dn *dn = ldb_get_schema_basedn(pyldb_Ldb_AsLdbContext(self));
if (dn == NULL)
return py_ldb_dn_copy(dn);
}
-static PyObject *py_ldb_get_config_basedn(PyLdbObject *self)
+static PyObject *py_ldb_get_config_basedn(PyLdbObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct ldb_dn *dn = ldb_get_config_basedn(pyldb_Ldb_AsLdbContext(self));
if (dn == NULL)
return py_ldb_dn_copy(dn);
}
-static PyObject *py_ldb_get_default_basedn(PyLdbObject *self)
+static PyObject *py_ldb_get_default_basedn(PyLdbObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct ldb_dn *dn = ldb_get_default_basedn(pyldb_Ldb_AsLdbContext(self));
if (dn == NULL)
const char *str = NULL;
Py_ssize_t size;
PyObject *item = PyList_GetItem(list, i);
- if (!(PyStr_Check(item) || PyUnicode_Check(item))) {
+ if (!(PyUnicode_Check(item) || PyUnicode_Check(item))) {
PyErr_Format(PyExc_TypeError, "%s should be strings", paramname);
talloc_free(ret);
return NULL;
return NULL;
}
- ret = PyStr_FromString(string);
+ ret = PyUnicode_FromString(string);
talloc_free(mem_ctx);
ldif = ldb_ldif_read_string(self->ldb_ctx, &s);
talloc_steal(mem_ctx, ldif);
if (ldif) {
- PyList_Append(list, ldb_ldif_to_pyobject(ldif));
+ int res = 0;
+ PyObject *py_ldif = ldb_ldif_to_pyobject(ldif);
+ if (py_ldif == NULL) {
+ Py_CLEAR(list);
+ PyErr_BadArgument();
+ talloc_free(mem_ctx);
+ return NULL;
+ }
+ res = PyList_Append(list, py_ldif);
+ Py_CLEAR(py_ldif);
+ if (res == -1) {
+ Py_CLEAR(list);
+ talloc_free(mem_ctx);
+ return NULL;
+ }
last_dn = ldif->msg->dn;
} else {
const char *last_dn_str = NULL;
PyErr_SetString(PyExc_ValueError,
"unable to parse LDIF "
"string at first chunk");
+ Py_CLEAR(list);
talloc_free(mem_ctx);
return NULL;
}
PyErr_SetString(PyExc_ValueError,
err_string);
talloc_free(mem_ctx);
+ Py_CLEAR(list);
return NULL;
}
}
return LDB_SUCCESS;
case LDB_REPLY_REFERRAL:
- reply->obj = PyStr_FromString(ares->referral);
+ reply->obj = PyUnicode_FromString(ares->referral);
if (reply->obj == NULL) {
TALLOC_FREE(ares);
return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR);
Py_RETURN_NONE;
}
-static PyObject *py_ldb_modules(PyLdbObject *self)
+static PyObject *py_ldb_modules(PyLdbObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct ldb_context *ldb = pyldb_Ldb_AsLdbContext(self);
PyObject *ret = PyList_New(0);
struct ldb_module *mod;
+ if (ret == NULL) {
+ return PyErr_NoMemory();
+ }
for (mod = ldb->modules; mod; mod = mod->next) {
- PyList_Append(ret, PyLdbModule_FromModule(mod));
+ PyObject *item = PyLdbModule_FromModule(mod);
+ int res = 0;
+ if (item == NULL) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Failed to load LdbModule");
+ Py_CLEAR(ret);
+ return NULL;
+ }
+ res = PyList_Append(ret, item);
+ Py_CLEAR(item);
+ if (res == -1) {
+ Py_CLEAR(ret);
+ return NULL;
+ }
}
return ret;
.write_hex_fn = ldb_handler_copy,
};
-static PyObject *py_ldb_register_test_extensions(PyLdbObject *self)
+static PyObject *py_ldb_register_test_extensions(PyLdbObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct ldb_context *ldb = pyldb_Ldb_AsLdbContext(self);
int ret;
NULL },
{ "get_config_basedn", (PyCFunction)py_ldb_get_config_basedn, METH_NOARGS,
NULL },
- { "connect", (PyCFunction)py_ldb_connect, METH_VARARGS|METH_KEYWORDS,
+ { "connect", PY_DISCARD_FUNC_SIG(PyCFunction, py_ldb_connect),
+ METH_VARARGS|METH_KEYWORDS,
"S.connect(url, flags=0, options=None) -> None\n"
"Connect to a LDB URL." },
- { "modify", (PyCFunction)py_ldb_modify, METH_VARARGS|METH_KEYWORDS,
+ { "modify", PY_DISCARD_FUNC_SIG(PyCFunction, py_ldb_modify),
+ METH_VARARGS|METH_KEYWORDS,
"S.modify(message, controls=None, validate=False) -> None\n"
"Modify an entry." },
- { "add", (PyCFunction)py_ldb_add, METH_VARARGS|METH_KEYWORDS,
+ { "add", PY_DISCARD_FUNC_SIG(PyCFunction, py_ldb_add),
+ METH_VARARGS|METH_KEYWORDS,
"S.add(message, controls=None) -> None\n"
"Add an entry." },
- { "delete", (PyCFunction)py_ldb_delete, METH_VARARGS|METH_KEYWORDS,
+ { "delete", PY_DISCARD_FUNC_SIG(PyCFunction, py_ldb_delete),
+ METH_VARARGS|METH_KEYWORDS,
"S.delete(dn, controls=None) -> None\n"
"Remove an entry." },
- { "rename", (PyCFunction)py_ldb_rename, METH_VARARGS|METH_KEYWORDS,
+ { "rename", PY_DISCARD_FUNC_SIG(PyCFunction, py_ldb_rename),
+ METH_VARARGS|METH_KEYWORDS,
"S.rename(old_dn, new_dn, controls=None) -> None\n"
"Rename an entry." },
- { "search", (PyCFunction)py_ldb_search, METH_VARARGS|METH_KEYWORDS,
+ { "search", PY_DISCARD_FUNC_SIG(PyCFunction, py_ldb_search),
+ METH_VARARGS|METH_KEYWORDS,
"S.search(base=None, scope=None, expression=None, attrs=None, controls=None) -> result\n"
"Search in a database.\n"
"\n"
":param controls: Optional list of controls\n"
":return: ldb.Result object\n"
},
- { "search_iterator", (PyCFunction)py_ldb_search_iterator, METH_VARARGS|METH_KEYWORDS,
+ { "search_iterator", PY_DISCARD_FUNC_SIG(PyCFunction,
+ py_ldb_search_iterator),
+ METH_VARARGS|METH_KEYWORDS,
"S.search_iterator(base=None, scope=None, expression=None, attrs=None, controls=None, timeout=None) -> iterator\n"
"Search in a database.\n"
"\n"
static PyObject *py_ldb_result_repr(PyLdbObject *self)
{
- return PyStr_FromString("<ldb result>");
+ return PyUnicode_FromString("<ldb result>");
}
return py_ret;
}
-static PyObject *py_ldb_search_iterator_result(PyLdbSearchIteratorObject *self)
+static PyObject *py_ldb_search_iterator_result(PyLdbSearchIteratorObject *self,
+ PyObject *Py_UNUSED(ignored))
{
PyObject *py_ret = NULL;
return py_ret;
}
-static PyObject *py_ldb_search_iterator_abandon(PyLdbSearchIteratorObject *self)
+static PyObject *py_ldb_search_iterator_abandon(PyLdbSearchIteratorObject *self,
+ PyObject *Py_UNUSED(ignored))
{
if (self->state.req == NULL) {
PyErr_SetString(PyExc_RuntimeError,
static PyObject *py_ldb_search_iterator_repr(PyLdbSearchIteratorObject *self)
{
- return PyStr_FromString("<ldb search iterator>");
+ return PyUnicode_FromString("<ldb search iterator>");
}
static PyTypeObject PyLdbSearchIterator = {
static PyObject *py_ldb_module_str(PyLdbModuleObject *self)
{
- return PyStr_FromString(pyldb_Module_AsModule(self)->ops->name);
+ return PyUnicode_FromString(pyldb_Module_AsModule(self)->ops->name);
}
-static PyObject *py_ldb_module_start_transaction(PyLdbModuleObject *self)
+static PyObject *py_ldb_module_start_transaction(PyLdbModuleObject *self,
+ PyObject *Py_UNUSED(ignored))
{
pyldb_Module_AsModule(self)->ops->start_transaction(pyldb_Module_AsModule(self));
Py_RETURN_NONE;
}
-static PyObject *py_ldb_module_end_transaction(PyLdbModuleObject *self)
+static PyObject *py_ldb_module_end_transaction(PyLdbModuleObject *self,
+ PyObject *Py_UNUSED(ignored))
{
pyldb_Module_AsModule(self)->ops->end_transaction(pyldb_Module_AsModule(self));
Py_RETURN_NONE;
}
-static PyObject *py_ldb_module_del_transaction(PyLdbModuleObject *self)
+static PyObject *py_ldb_module_del_transaction(PyLdbModuleObject *self,
+ PyObject *Py_UNUSED(ignored))
{
pyldb_Module_AsModule(self)->ops->del_transaction(pyldb_Module_AsModule(self));
Py_RETURN_NONE;
}
static PyMethodDef py_ldb_module_methods[] = {
- { "search", (PyCFunction)py_ldb_module_search, METH_VARARGS|METH_KEYWORDS, NULL },
+ { "search", PY_DISCARD_FUNC_SIG(PyCFunction, py_ldb_module_search),
+ METH_VARARGS|METH_KEYWORDS, NULL },
{ "add", (PyCFunction)py_ldb_module_add, METH_VARARGS, NULL },
{ "modify", (PyCFunction)py_ldb_module_modify, METH_VARARGS, NULL },
{ "rename", (PyCFunction)py_ldb_module_rename, METH_VARARGS, NULL },
ret = PyStr_FromFormat("MessageElement([%s])", element_str);
talloc_free(element_str);
} else {
- ret = PyStr_FromString("MessageElement([])");
+ ret = PyUnicode_FromString("MessageElement([])");
}
return ret;
Py_RETURN_NONE;
}
-static PyObject *py_ldb_msg_keys(PyLdbMessageObject *self)
+static PyObject *py_ldb_msg_keys(PyLdbMessageObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct ldb_message *msg = pyldb_Message_AsMessage(self);
Py_ssize_t i, j = 0;
PyObject *obj = PyList_New(msg->num_elements+(msg->dn != NULL?1:0));
if (msg->dn != NULL) {
- PyList_SetItem(obj, j, PyStr_FromString("dn"));
+ PyList_SetItem(obj, j, PyUnicode_FromString("dn"));
j++;
}
for (i = 0; i < msg->num_elements; i++) {
- PyList_SetItem(obj, j, PyStr_FromString(msg->elements[i].name));
+ PyList_SetItem(obj, j, PyUnicode_FromString(msg->elements[i].name));
j++;
}
return obj;
return PyObject_FromLdbValue(&el->values[idx]);
}
-static PyObject *py_ldb_msg_items(PyLdbMessageObject *self)
+static PyObject *py_ldb_msg_items(PyLdbMessageObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct ldb_message *msg = pyldb_Message_AsMessage(self);
Py_ssize_t i, j = 0;
PyObject *l = PyList_New(msg->num_elements + (msg->dn == NULL?0:1));
+ if (l == NULL) {
+ return PyErr_NoMemory();
+ }
if (msg->dn != NULL) {
+ PyObject *value = NULL;
PyObject *obj = pyldb_Dn_FromDn(msg->dn);
- PyList_SetItem(l, 0, Py_BuildValue("(sO)", "dn", obj));
+ int res = 0;
+ value = Py_BuildValue("(sO)", "dn", obj);
Py_CLEAR(obj);
+ if (value == NULL) {
+ Py_CLEAR(l);
+ return NULL;
+ }
+ res = PyList_SetItem(l, 0, value);
+ if (res == -1) {
+ Py_CLEAR(l);
+ return NULL;
+ }
j++;
}
for (i = 0; i < msg->num_elements; i++, j++) {
+ PyObject *value = NULL;
PyObject *py_el = PyLdbMessageElement_FromMessageElement(&msg->elements[i], msg->elements);
- PyObject *value = Py_BuildValue("(sO)", msg->elements[i].name, py_el);
+ int res = 0;
Py_CLEAR(py_el);
- PyList_SetItem(l, j, value);
+ value = Py_BuildValue("(sO)", msg->elements[i].name, py_el);
+ if (value == NULL ) {
+ Py_CLEAR(l);
+ return NULL;
+ }
+ res = PyList_SetItem(l, 0, value);
+ if (res == -1) {
+ Py_CLEAR(l);
+ return NULL;
+ }
}
return l;
}
-static PyObject *py_ldb_msg_elements(PyLdbMessageObject *self)
+static PyObject *py_ldb_msg_elements(PyLdbMessageObject *self,
+ PyObject *Py_UNUSED(ignored))
{
struct ldb_message *msg = pyldb_Message_AsMessage(self);
Py_ssize_t i = 0;
PyErr_SetString(PyExc_ValueError, "Invalid MessageElement object");
return NULL;
}
-
+ if (el->name == NULL) {
+ PyErr_SetString(PyExc_ValueError,
+ "The element has no name");
+ return NULL;
+ }
ret = ldb_msg_add_empty(msg, el->name, el->flags, &el_new);
PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, NULL);
"Message.from_dict(ldb, dict, mod_flag=FLAG_MOD_REPLACE) -> ldb.Message\n"
"Class method to create ldb.Message object from Dictionary.\n"
"mod_flag is one of FLAG_MOD_ADD, FLAG_MOD_REPLACE or FLAG_MOD_DELETE."},
- { "keys", (PyCFunction)py_ldb_msg_keys, METH_NOARGS,
+ { "keys", (PyCFunction)py_ldb_msg_keys, METH_NOARGS,
"S.keys() -> list\n\n"
"Return sequence of all attribute names." },
{ "remove", (PyCFunction)py_ldb_msg_remove_attr, METH_VARARGS,
"S.remove(name)\n\n"
"Remove all entries for attributes with the specified name."},
- { "get", (PyCFunction)py_ldb_msg_get, METH_VARARGS | METH_KEYWORDS,
+ { "get", PY_DISCARD_FUNC_SIG(PyCFunction, py_ldb_msg_get),
+ METH_VARARGS | METH_KEYWORDS,
"msg.get(name,default=None,idx=None) -> string\n"
"idx is the index into the values array\n"
"if idx is None, then a list is returned\n"
{
PyObject *list, *iter;
- list = py_ldb_msg_keys(self);
+ list = py_ldb_msg_keys(self, NULL);
iter = PyObject_GetIter(list);
Py_DECREF(list);
return iter;
for (len = 0; req->op.search.attrs[len]; len++);
py_attrs = PyList_New(len);
for (i = 0; i < len; i++)
- PyList_SetItem(py_attrs, i, PyStr_FromString(req->op.search.attrs[i]));
+ PyList_SetItem(py_attrs, i, PyUnicode_FromString(req->op.search.attrs[i]));
}
py_result = PyObject_CallMethod(py_ldb, discard_const_p(char, "search"),
int ret;
struct ldb_module_ops *ops;
PyObject *input;
+ PyObject *tmp;
if (!PyArg_ParseTuple(args, "O", &input))
return NULL;
return NULL;
}
- ops->name = talloc_strdup(ops, PyStr_AsUTF8(PyObject_GetAttrString(input, discard_const_p(char, "name"))));
+ tmp = PyObject_GetAttrString(input, discard_const_p(char, "name"));
+ ops->name = talloc_strdup(ops, PyStr_AsUTF8(tmp));
+ Py_XDECREF(tmp);
Py_INCREF(input);
ops->private_data = input;
ops->init_context = py_module_init;
if (!PyArg_ParseTuple(args, "l", &t_val))
return NULL;
tresult = ldb_timestring(NULL, (time_t) t_val);
- ret = PyStr_FromString(tresult);
+ ret = PyUnicode_FromString(tresult);
talloc_free(tresult);
return ret;
}
PyErr_SetString(PyExc_TypeError, "unable to encode binary string");
return NULL;
}
- ret = PyStr_FromString(encoded);
+ ret = PyUnicode_FromString(encoded);
talloc_free(encoded);
return ret;
}
{ "valid_attr_name", py_valid_attr_name, METH_VARARGS,
"S.valid_attr_name(name) -> bool\n\nn"
"Check whether the supplied name is a valid attribute name." },
- { "open", (PyCFunction)py_ldb_new, METH_VARARGS|METH_KEYWORDS,
+ { "open", PY_DISCARD_FUNC_SIG(PyCFunction,py_ldb_new),
+ METH_VARARGS|METH_KEYWORDS,
"S.open() -> Ldb\n\n"
"Open a new LDB context." },
{ "binary_encode", py_binary_encode, METH_VARARGS,
ADD_LDB_INT(FLG_ENABLE_TRACING);
ADD_LDB_INT(FLG_DONT_CREATE_DB);
+ ADD_LDB_INT(PACKING_FORMAT);
+ ADD_LDB_INT(PACKING_FORMAT_V2);
/* Historical misspelling */
PyModule_AddIntConstant(m, "ERR_ALIAS_DEREFERINCING_PROBLEM", LDB_ERR_ALIAS_DEREFERENCING_PROBLEM);
ADD_LDB_STRING(SYNTAX_DN);
ADD_LDB_STRING(SYNTAX_DIRECTORY_STRING);
ADD_LDB_STRING(SYNTAX_INTEGER);
+ ADD_LDB_STRING(SYNTAX_ORDERED_INTEGER);
ADD_LDB_STRING(SYNTAX_BOOLEAN);
ADD_LDB_STRING(SYNTAX_OCTET_STRING);
ADD_LDB_STRING(SYNTAX_UTC_TIME);