diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/tdb/python/tests/simple.py | 6 | ||||
-rw-r--r-- | source4/lib/tdb/tdb.i | 28 | ||||
-rw-r--r-- | source4/lib/tdb/tdb_wrap.c | 19 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/SWIG.pm | 2 |
4 files changed, 26 insertions, 29 deletions
diff --git a/source4/lib/tdb/python/tests/simple.py b/source4/lib/tdb/python/tests/simple.py index 4600f02f14..0e0ef0251e 100644 --- a/source4/lib/tdb/python/tests/simple.py +++ b/source4/lib/tdb/python/tests/simple.py @@ -10,6 +10,12 @@ import tdb from unittest import TestCase import os + +class OpenTdbTests(TestCase): + def test_nonexistant_read(self): + self.assertRaises(IOError, tdb.Tdb, "/some/nonexistant/file", 0, tdb.DEFAULT, os.O_RDWR) + + class SimpleTdbTests(TestCase): def setUp(self): super(SimpleTdbTests, self).setUp() diff --git a/source4/lib/tdb/tdb.i b/source4/lib/tdb/tdb.i index 5bb6506d93..41eaf77202 100644 --- a/source4/lib/tdb/tdb.i +++ b/source4/lib/tdb/tdb.i @@ -108,7 +108,6 @@ enum TDB_ERROR { TDB_ERR_RDONLY }; -%rename(Tdb) tdb; %rename(lock_all) tdb_context::lockall; %rename(unlock_all) tdb_context::unlockall; @@ -135,23 +134,20 @@ enum TDB_ERROR { $1 = TDB_REPLACE; } +%rename(Tdb) tdb; +%typemap(out,noblock=1) tdb * { + /* Throw an IOError exception from errno if tdb_open() returns NULL */ + if ($1 == NULL) { + PyErr_SetFromErrno(PyExc_IOError); + SWIG_fail; + } + $result = SWIG_NewPointerObj($1, $1_descriptor, 0); +} + typedef struct tdb_context { %extend { - tdb(const char *name, int hash_size, - int tdb_flags, - int open_flags, mode_t mode) - { - tdb *ret = tdb_open(name, hash_size, tdb_flags, open_flags, mode); - - /* Throw an IOError exception from errno if tdb_open() returns - NULL */ - if (ret == NULL) { - PyErr_SetFromErrno(PyExc_IOError); - SWIG_fail; - } - -fail: - return ret; + tdb(const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode) { + return tdb_open(name, hash_size, tdb_flags, open_flags, mode); } enum TDB_ERROR error(); ~tdb() { tdb_close($self); } diff --git a/source4/lib/tdb/tdb_wrap.c b/source4/lib/tdb/tdb_wrap.c index 1ba7481af0..a58442b521 100644 --- a/source4/lib/tdb/tdb_wrap.c +++ b/source4/lib/tdb/tdb_wrap.c @@ -2748,17 +2748,7 @@ SWIG_AsVal_int (PyObject * obj, int *val) } SWIGINTERN tdb *new_tdb(char const *name,int hash_size,int tdb_flags,int open_flags,mode_t mode){ - tdb *ret = tdb_open(name, hash_size, tdb_flags, open_flags, mode); - - /* Throw an IOError exception from errno if tdb_open() returns - NULL */ - if (ret == NULL) { - PyErr_SetFromErrno(PyExc_IOError); - SWIG_fail; - } - -fail: - return ret; + return tdb_open(name, hash_size, tdb_flags, open_flags, mode); } SWIGINTERN void delete_tdb(tdb *self){ tdb_close(self); } @@ -2870,7 +2860,12 @@ SWIGINTERN PyObject *_wrap_new_Tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *arg arg5 = (mode_t)(val5); } result = (tdb *)new_tdb((char const *)arg1,arg2,arg3,arg4,arg5); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_tdb_context, SWIG_POINTER_OWN | 0 ); + /* Throw an IOError exception from errno if tdb_open() returns NULL */ + if (result == NULL) { + PyErr_SetFromErrno(PyExc_IOError); + SWIG_fail; + } + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_tdb_context, 0); if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); return resultobj; fail: diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/SWIG.pm b/source4/pidl/lib/Parse/Pidl/Samba4/SWIG.pm index 58b52df8d3..14424cf260 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/SWIG.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/SWIG.pm @@ -105,7 +105,7 @@ sub ParseInterface($$) pidl ""; pidl "status = dcerpc_$fn->{NAME}(\$self->pipe, mem_ctx, &r);"; pidl "if (NT_STATUS_IS_ERR(status)) {"; - pidl "\treturn status;"; + indent; pidl "return status;"; deindent; pidl "}"; pidl ""; pidl "/* Set out arguments */"; |