From 872446a5c77ef18c0fb7510577345c7a31490d00 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 3 May 2005 07:10:46 +0000 Subject: r6592: Throw an IOError exception if tdb_open() or tdb_open_Ex() returns NULL. --- source/scripting/swig/tdb.i | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/scripting/swig') diff --git a/source/scripting/swig/tdb.i b/source/scripting/swig/tdb.i index b381487ebc4..6c6c4af8cdc 100644 --- a/source/scripting/swig/tdb.i +++ b/source/scripting/swig/tdb.i @@ -103,6 +103,16 @@ typedef int mode_t; #define TDB_CONVERT 16 /* convert endian (internal use) */ #define TDB_BIGENDIAN 32 /* header is big-endian (internal use) */ +/* Throw an IOError exception if tdb_open() or tdb_open_ex() returns NULL */ + +%exception { + $action + if (result == NULL) { + PyErr_SetFromErrno(PyExc_IOError); + SWIG_fail; + } +} + %rename tdb_open open; TDB_CONTEXT *tdb_open(const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode); @@ -113,6 +123,8 @@ TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags, tdb_log_func log_fn, tdb_hash_func hash_fn); +%exception; + %rename tdb_reopen reopen; int tdb_reopen(TDB_CONTEXT *tdb); -- cgit