static PyObject *py_ldb_error;
static PyTypeObject PySambaLdb;
-static void PyErr_SetLdbError(PyObject *error, int ret, struct ldb_context *ldb_ctx)
-{
- if (ret == LDB_ERR_PYTHON_EXCEPTION)
- return; /* Python exception should already be set, just keep that */
-
- PyErr_SetObject(error,
- Py_BuildValue(discard_const_p(char, "(i,s)"), ret,
- ldb_ctx == NULL?ldb_strerror(ret):ldb_errstring(ldb_ctx)));
-}
-
static PyObject *py_ldb_set_loadparm(PyObject *self, PyObject *args)
{
PyObject *py_lp_ctx;
.tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
};
-static void PyErr_SetLdbError(PyObject *error, int ret, struct ldb_context *ldb_ctx)
-{
- PyObject *exc = NULL;
- if (ret == LDB_ERR_PYTHON_EXCEPTION) {
- return; /* Python exception should already be set, just keep that */
- }
- exc = Py_BuildValue("(i,s)", ret,
- ldb_ctx == NULL?ldb_strerror(ret):ldb_errstring(ldb_ctx));
- if (exc == NULL) {
- /*
- * Py_BuildValue failed, and will have set its own exception.
- * It isn't the one we wanted, but it will have to do.
- * This is all very unexpected.
- */
- fprintf(stderr, "could not make LdbError %d!\n", ret);
- return;
- }
- PyErr_SetObject(error, exc);
- Py_DECREF(exc);
-}
-
static PyObject *py_ldb_bytes_str(PyBytesObject *self)
{
char *msg = NULL;
struct ldb_control *data;
} PyLdbControlObject;
+void PyErr_SetLdbError(PyObject *error, int ret, struct ldb_context *ldb_ctx);
+
#define PyErr_LDB_ERROR_IS_ERR_RAISE(err,ret,ldb) do { \
if (ret != LDB_SUCCESS) { \
PyErr_SetLdbError(err, ret, ldb); \
py_ret->dn = dn;
return (PyObject *)py_ret;
}
+
+void PyErr_SetLdbError(PyObject *error, int ret, struct ldb_context *ldb_ctx)
+{
+ PyObject *exc = NULL;
+ if (ret == LDB_ERR_PYTHON_EXCEPTION) {
+ return; /* Python exception should already be set, just keep that */
+ }
+ exc = Py_BuildValue("(i,s)", ret,
+ ldb_ctx == NULL?ldb_strerror(ret):ldb_errstring(ldb_ctx));
+ if (exc == NULL) {
+ /*
+ * Py_BuildValue failed, and will have set its own exception.
+ * It isn't the one we wanted, but it will have to do.
+ * This is all very unexpected.
+ */
+ fprintf(stderr, "could not make LdbError %d!\n", ret);
+ return;
+ }
+ PyErr_SetObject(error, exc);
+ Py_DECREF(exc);
+}
return result;
}
-static void PyErr_SetLdbError(PyObject *error, int ret, struct ldb_context *ldb_ctx)
-{
- if (ret == LDB_ERR_PYTHON_EXCEPTION)
- return; /* Python exception should already be set, just keep that */
-
- PyErr_SetObject(error,
- Py_BuildValue(discard_const_p(char, "(i,s)"), ret,
- ldb_ctx == NULL?ldb_strerror(ret):ldb_errstring(ldb_ctx)));
-}
-
static PyObject *py_samdb_server_site_name(PyObject *self, PyObject *args)
{
PyObject *py_ldb, *result;