diff -Nru qdbm-python-0.0.1/common.pxi qdbm-python-0.0.2/common.pxi --- qdbm-python-0.0.1/common.pxi 2007-12-06 22:41:21.000000000 +0100 +++ qdbm-python-0.0.2/common.pxi 2007-12-06 23:44:54.000000000 +0100 @@ -31,3 +31,6 @@ int cblistbsearch(CBLIST *list, char *ptr, int size) char *cblistdump(CBLIST *list, int *sp) CBLIST *cblistload(char *ptr, int size) + +class QDBMError(Exception): + ecode = None diff -Nru qdbm-python-0.0.1/curia.pxi qdbm-python-0.0.2/curia.pxi --- qdbm-python-0.0.1/curia.pxi 2007-12-06 22:41:21.000000000 +0100 +++ qdbm-python-0.0.2/curia.pxi 2007-12-07 00:20:31.000000000 +0100 @@ -48,7 +48,7 @@ CR_DCAT # concatenate values -class CuriaError(Exception): +class CuriaError(QDBMError): def __init__(self): self.ecode = dpecode Exception.__init__(self, "%s(%d)" % (dperrmsg(dpecode), dpecode)) @@ -69,11 +69,13 @@ self.close() def close(self): - if self._curia: - if not crclose(self._curia): - raise CuriaError() + cdef CURIA *_handle + if self._curia: + _handle = self._curia self._curia = NULL + if not crclose(_handle): + raise CuriaError() cdef _cput(self, key, val, dmode): cdef int ksize, vsize @@ -318,7 +320,10 @@ s = criternext(self._curia._curia, &sp) if not s: - raise StopIteration + if dpecode == DP_ENOITEM: + raise StopIteration + else: + raise CuriaError() try: return PyString_FromStringAndSize(s, sp) diff -Nru qdbm-python-0.0.1/depot.pxi qdbm-python-0.0.2/depot.pxi --- qdbm-python-0.0.1/depot.pxi 2007-12-06 22:41:21.000000000 +0100 +++ qdbm-python-0.0.2/depot.pxi 2007-12-07 00:17:06.000000000 +0100 @@ -74,7 +74,7 @@ char *dperrmsg(int ecode) -class DepotError(Exception): +class DepotError(QDBMError): def __init__(self): self.ecode = dpecode Exception.__init__(self, "%s(%d)" % (dperrmsg(dpecode), dpecode)) @@ -101,11 +101,13 @@ self.close() def close(self): - if self._depot: - if not dpclose(self._depot): - raise DepotError() + cdef DEPOT *_handle + if self._depot: + _handle = self._depot self._depot = NULL + if not dpclose(_handle): + raise DepotError() cdef _cput(self, key, val, dmode): cdef int ksize, vsize @@ -290,7 +292,10 @@ s = dpiternext(self._depot._depot, &sp) if not s: - raise StopIteration + if dpecode == DP_ENOITEM: + raise StopIteration + else: + raise DepotError() try: return PyString_FromStringAndSize(s, sp) diff -Nru qdbm-python-0.0.1/_qdbm_vista.pyx qdbm-python-0.0.2/_qdbm_vista.pyx --- qdbm-python-0.0.1/_qdbm_vista.pyx 2007-12-06 22:41:21.000000000 +0100 +++ qdbm-python-0.0.2/_qdbm_vista.pyx 2007-12-07 00:23:52.000000000 +0100 @@ -86,7 +86,7 @@ -class VistaError(Exception): +class VistaError(QDBMError): def __init__(self): self.ecode = dpecode Exception.__init__(self, "%s(%d)" % (dperrmsg(dpecode), dpecode)) @@ -109,7 +109,7 @@ if ctypes: VILLA_CALLBACK = CFUNCTYPE(c_int, POINTER(c_byte), c_int, POINTER(c_byte), c_int) - _VLOPEN = ctypes.cdll.LoadLibrary("qdbm").vstopen # xxx: Is vstopen a public API? + _VLOPEN = ctypes.cdll.LoadLibrary("libqdbm.so").vstopen # xxx: Is vstopen a public API? _VLOPEN.resttype = c_void_p @@ -158,13 +158,15 @@ return self._cmpfunc(abuf.value, bbuf.value) def close(self): - if self._villa: - if not vlclose(self._villa): - raise VistaError() + cdef VILLA *_handle + if self._villa: + _handle = self._villa self._villa = NULL self._cfunc = None self._cmpfunc = None + if vlclose(_handle): + raise VistaError() cdef _cput(self, key, val, dmode): cdef int ksize, vsize diff -Nru qdbm-python-0.0.1/setup.py qdbm-python-0.0.2/setup.py --- qdbm-python-0.0.1/setup.py 2007-12-06 22:41:21.000000000 +0100 +++ qdbm-python-0.0.2/setup.py 2007-12-06 23:06:01.000000000 +0100 @@ -32,7 +32,7 @@ setup( name = "qdbm", - version = "0.0.1", + version = "0.0.2", description = "Python interface for QDBM", author = "Atsuo Ishimoto", author_email = "ishimoto@gembook.org", diff -Nru qdbm-python-0.0.1/villa.pxi qdbm-python-0.0.2/villa.pxi --- qdbm-python-0.0.1/villa.pxi 2007-12-06 22:41:21.000000000 +0100 +++ qdbm-python-0.0.2/villa.pxi 2007-12-07 00:23:05.000000000 +0100 @@ -81,7 +81,7 @@ -class VillaError(Exception): +class VillaError(QDBMError): def __init__(self): self.ecode = dpecode Exception.__init__(self, "%s(%d)" % (dperrmsg(dpecode), dpecode)) @@ -103,7 +103,7 @@ if ctypes: VILLA_CALLBACK = CFUNCTYPE(c_int, POINTER(c_byte), c_int, POINTER(c_byte), c_int) - _VLOPEN = ctypes.cdll.LoadLibrary("qdbm").vlopen + _VLOPEN = ctypes.cdll.LoadLibrary("libqdbm.so").vlopen _VLOPEN.resttype = c_void_p cdef class Villa: @@ -151,13 +151,15 @@ return self._cmpfunc(abuf.value, bbuf.value) def close(self): - if self._villa: - if not vlclose(self._villa): - raise VillaError() + cdef VILLA *_handle + if self._villa: + _handle = self._villa self._cfunc = None self._cmpfunc = None self._villa = NULL + if not vlclose(_handle): + raise VillaError() cdef _cput(self, key, val, dmode): cdef int ksize, vsize