summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-12-24 11:02:45 -0600
committerStefan Metzmacher <metze@samba.org>2007-12-26 11:57:03 -0600
commita822a14d1ec7e2635c3d004cc7488e4fd27b8d16 (patch)
tree50818c805dfbf204941c3d7b9bc8ec5482ee472e
parent9faf93c7b0e00edcdc3f535ea69fc2c1bb6eeeb3 (diff)
downloadsamba-a822a14d1ec7e2635c3d004cc7488e4fd27b8d16.tar.gz
samba-a822a14d1ec7e2635c3d004cc7488e4fd27b8d16.tar.bz2
samba-a822a14d1ec7e2635c3d004cc7488e4fd27b8d16.zip
r26584: Fix exception handling in ldb constructor.
(This used to be commit 5383cf8e69233b3cb7c1876f52644537e459dea6)
-rw-r--r--source4/lib/ldb/ldb.i27
-rw-r--r--source4/lib/ldb/ldb.py5
-rw-r--r--source4/lib/ldb/ldb_wrap.c65
3 files changed, 18 insertions, 79 deletions
diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i
index ffb69986e5..7960d38bb5 100644
--- a/source4/lib/ldb/ldb.i
+++ b/source4/lib/ldb/ldb.i
@@ -463,25 +463,7 @@ PyObject *PyExc_LdbError;
/* Top-level ldb operations */
typedef struct ldb_context {
%extend {
- ldb(const char *url=NULL, unsigned int flags = 0,
- const char *options[] = NULL)
- {
- ldb *ldb_ctx = ldb_init(NULL);
-
- if (url != NULL) {
- int ret;
-
- ret = ldb_connect(ldb_ctx, url, flags, options);
- if (ret != LDB_SUCCESS)
- SWIG_exception(SWIG_ValueError, ldb_errstring(ldb_ctx));
- }
-
- return ldb_ctx;
-
-fail:
- talloc_free(ldb_ctx);
- return NULL;
- }
+ ldb(void) { return ldb_init(NULL); }
ldb_error connect(const char *url, unsigned int flags = 0,
const char *options[] = NULL);
@@ -576,6 +558,13 @@ fail:
#endif
}
+ %pythoncode {
+ def __init__(self, url=None, flags=0, options=None):
+ _ldb.Ldb_swiginit(self,_ldb.new_Ldb())
+ if url is not None:
+ self.connect(url, flags, options)
+ }
+
} ldb;
%typemap(in,noblock=1) struct ldb_dn *;
diff --git a/source4/lib/ldb/ldb.py b/source4/lib/ldb/ldb.py
index 160fa88dff..ebf8f6025a 100644
--- a/source4/lib/ldb/ldb.py
+++ b/source4/lib/ldb/ldb.py
@@ -176,6 +176,11 @@ class Ldb(object):
def __init__(self, *args, **kwargs):
_ldb.Ldb_swiginit(self,_ldb.new_Ldb(*args, **kwargs))
__swig_destroy__ = _ldb.delete_Ldb
+ def __init__(self, url=None, flags=0, options=None):
+ _ldb.Ldb_swiginit(self,_ldb.new_Ldb())
+ if url is not None:
+ self.connect(url, flags, options)
+
Ldb.connect = new_instancemethod(_ldb.Ldb_connect,None,Ldb)
Ldb.search = new_instancemethod(_ldb.Ldb_search,None,Ldb)
Ldb.delete = new_instancemethod(_ldb.Ldb_delete,None,Ldb)
diff --git a/source4/lib/ldb/ldb_wrap.c b/source4/lib/ldb/ldb_wrap.c
index 2272654b2c..d29c0289f6 100644
--- a/source4/lib/ldb/ldb_wrap.c
+++ b/source4/lib/ldb/ldb_wrap.c
@@ -2971,6 +2971,7 @@ static void py_ldb_debug(void *context, enum ldb_debug_level level, const char *
PyObject *PyExc_LdbError;
+SWIGINTERN ldb *new_ldb(){ return ldb_init(NULL); }
SWIGINTERN int
SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val)
@@ -3031,23 +3032,6 @@ SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val)
return res;
}
-SWIGINTERN ldb *new_ldb(char const *url,unsigned int flags,char const *options[]){
- ldb *ldb_ctx = ldb_init(NULL);
-
- if (url != NULL) {
- int ret;
-
- ret = ldb_connect(ldb_ctx, url, flags, options);
- if (ret != 0)
- SWIG_exception(SWIG_ValueError, ldb_errstring(ldb_ctx));
- }
-
- return ldb_ctx;
-
-fail:
- talloc_free(ldb_ctx);
- return NULL;
- }
SWIGINTERN void delete_ldb(ldb *self){ talloc_free(self); }
SWIGINTERN ldb_error ldb_add__SWIG_1(ldb *self,PyObject *py_msg){
ldb_error ret;
@@ -4189,54 +4173,15 @@ fail:
}
-SWIGINTERN PyObject *_wrap_new_Ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_new_Ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- char *arg1 = (char *) NULL ;
- unsigned int arg2 = (unsigned int) 0 ;
- char **arg3 = (char **) (char **)NULL ;
ldb *result = 0 ;
- int res1 ;
- char *buf1 = 0 ;
- int alloc1 = 0 ;
- unsigned int val2 ;
- int ecode2 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- PyObject * obj2 = 0 ;
- char * kwnames[] = {
- (char *) "url",(char *) "flags",(char *) "options", NULL
- };
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:new_Ldb",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
- if (obj0) {
- res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Ldb" "', argument " "1"" of type '" "char const *""'");
- }
- arg1 = (char *)(buf1);
- }
- if (obj1) {
- ecode2 = SWIG_AsVal_unsigned_SS_int(obj1, &val2);
- if (!SWIG_IsOK(ecode2)) {
- SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_Ldb" "', argument " "2"" of type '" "unsigned int""'");
- }
- arg2 = (unsigned int)(val2);
- }
- if (obj2) {
- res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_p_char, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_Ldb" "', argument " "3"" of type '" "char const *[]""'");
- }
- arg3 = (char **)(argp3);
- }
- result = (ldb *)new_ldb((char const *)arg1,arg2,(char const *(*))arg3);
+ if (!SWIG_Python_UnpackTuple(args,"new_Ldb",0,0,0)) SWIG_fail;
+ result = (ldb *)new_ldb();
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_context, SWIG_POINTER_NEW | 0 );
- if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
return resultobj;
fail:
- if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
return NULL;
}
@@ -5338,7 +5283,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"Message_swigregister", Message_swigregister, METH_VARARGS, NULL},
{ (char *)"Message_swiginit", Message_swiginit, METH_VARARGS, NULL},
{ (char *)"ldb_ldif_to_pyobject", (PyCFunction) _wrap_ldb_ldif_to_pyobject, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"new_Ldb", (PyCFunction) _wrap_new_Ldb, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"new_Ldb", (PyCFunction)_wrap_new_Ldb, METH_NOARGS, NULL},
{ (char *)"Ldb_connect", (PyCFunction) _wrap_Ldb_connect, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"delete_Ldb", (PyCFunction)_wrap_delete_Ldb, METH_O, NULL},
{ (char *)"Ldb_search", (PyCFunction) _wrap_Ldb_search, METH_VARARGS | METH_KEYWORDS, NULL},