[h5py] 54/455: Fixed segfault, infinite loop, more cimport BS, moved h5e into h5

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:16 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to annotated tag 1.3.0
in repository h5py.

commit 1db40efd45137578b1efe844662d20ca5ea2c736
Author: andrewcollette <andrew.collette at gmail.com>
Date:   Tue Jun 17 06:01:14 2008 +0000

    Fixed segfault, infinite loop, more cimport BS, moved h5e into h5
---
 h5py/__init__.py |   1 -
 h5py/h5.pxd      | 208 ++++++++++++++++++++++++++--
 h5py/h5.pyx      | 413 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 h5py/h5a.pxd     |   3 +-
 h5py/h5e.pxd     | 220 -----------------------------
 h5py/h5e.pyx     | 406 ------------------------------------------------------
 h5py/h5g.pyx     |   3 +-
 h5py/h5i.pxd     |   2 +-
 h5py/h5i.pyx     |   2 +-
 h5py/h5p.pyx     |  34 ++---
 h5py/h5t.pxd     |   4 +-
 h5py/h5t.pyx     |  11 +-
 setup.py         |   2 +-
 13 files changed, 608 insertions(+), 701 deletions(-)

diff --git a/h5py/__init__.py b/h5py/__init__.py
index b731752..a398ff4 100644
--- a/h5py/__init__.py
+++ b/h5py/__init__.py
@@ -23,7 +23,6 @@ __doc__ = \
 """
 
 import utils, h5, h5f, h5g, h5s, h5t, h5d, h5a, h5p, h5z, h5i
-import tests
 import version
 
 __doc__ = __doc__ % version.version
diff --git a/h5py/h5.pxd b/h5py/h5.pxd
index 1526609..b63b25a 100644
--- a/h5py/h5.pxd
+++ b/h5py/h5.pxd
@@ -41,22 +41,9 @@ cdef extern from "hdf5.h":
   # reflection
   ctypedef enum H5I_type_t:
     H5I_BADID        = -1,  # /*invalid Group                    */
-    H5I_FILE        = 1,    # /*group ID for File objects            */
-    H5I_GROUP,              # /*group ID for Group objects            */
-    H5I_DATATYPE,           # /*group ID for Datatype objects            */
-    H5I_DATASPACE,          # /*group ID for Dataspace objects        */
-    H5I_DATASET,            # /*group ID for Dataset objects            */
-    H5I_ATTR,               # /*group ID for Attribute objects        */
-    H5I_REFERENCE,          # /*group ID for Reference objects        */
-    H5I_VFL,                # /*group ID for virtual file layer        */
-    H5I_GENPROP_CLS,        # /*group ID for generic property list classes */
-    H5I_GENPROP_LST,        # /*group ID for generic property lists       */
-    H5I_NGROUPS             # /*number of valid groups, MUST BE LAST!        */
 
   # --- Reflection ------------------------------------------------------------
   H5I_type_t H5Iget_type(hid_t obj_id) except *
-  ssize_t    H5Iget_name( hid_t obj_id, char *name, size_t size) except *
-  hid_t      H5Iget_file_id(hid_t obj_id) except *
   int        H5Idec_ref(hid_t obj_id) except *
   int        H5Iget_ref(hid_t obj_id) except *
   int        H5Iinc_ref(hid_t obj_id) except *
@@ -65,13 +52,204 @@ cdef extern from "hdf5.h":
   herr_t H5get_libversion(unsigned *majnum, unsigned *minnum,
                           unsigned *relnum ) except *
 
+  # --- Error handling --------------------------------------------------------
+
+  # Major error numbers
+  ctypedef enum H5E_major_t:
+    H5E_NONE_MAJOR       = 0,   # special zero, no error                     
+    H5E_ARGS,                   # invalid arguments to routine               
+    H5E_RESOURCE,               # resource unavailable                       
+    H5E_INTERNAL,               #  Internal error (too specific to document)
+    H5E_FILE,                   # file Accessability                         
+    H5E_IO,                     # Low-level I/O                              
+    H5E_FUNC,                   # function Entry/Exit                        
+    H5E_ATOM,                   # object Atom                                
+    H5E_CACHE,                  # object Cache                               
+    H5E_BTREE,                  # B-Tree Node                                
+    H5E_SYM,                    # symbol Table                               
+    H5E_HEAP,                   # Heap                                       
+    H5E_OHDR,                   # object Header                              
+    H5E_DATATYPE,               # Datatype                                   
+    H5E_DATASPACE,              # Dataspace                                  
+    H5E_DATASET,                # Dataset                                    
+    H5E_STORAGE,                # data storage                               
+    H5E_PLIST,                  # Property lists                             
+    H5E_ATTR,                   # Attribute                                  
+    H5E_PLINE,                  # Data filters                               
+    H5E_EFL,                    # External file list                         
+    H5E_REFERENCE,              # References                                 
+    H5E_VFL,                    # Virtual File Layer                 
+    H5E_TBBT,                   # Threaded, Balanced, Binary Trees           
+    H5E_TST,                    # Ternary Search Trees                       
+    H5E_RS,                     # Reference Counted Strings                  
+    H5E_ERROR,                  # Error API                                  
+    H5E_SLIST                   # Skip Lists                                 
+
+  # Minor error numbers
+  ctypedef enum H5E_minor_t:
+    H5E_NONE_MINOR       = 0
+
+    #  Argument errors 
+    H5E_UNINITIALIZED,          # information is unitialized
+    H5E_UNSUPPORTED,            # feature is unsupported
+    H5E_BADTYPE,                # incorrect type found
+    H5E_BADRANGE,               # argument out of range
+    H5E_BADVALUE,               # bad value for argument
+
+    #  Resource errors 
+    H5E_NOSPACE,                # no space available for allocation
+    H5E_CANTCOPY,               # unable to copy object
+    H5E_CANTFREE,               # unable to free object
+    H5E_ALREADYEXISTS,          # Object already exists
+    H5E_CANTLOCK,               # Unable to lock object
+    H5E_CANTUNLOCK,             # Unable to unlock object
+    H5E_CANTGC,                 # Unable to garbage collect
+    H5E_CANTGETSIZE,            # Unable to compute size
+
+    #  File accessability errors 
+    H5E_FILEEXISTS,             # file already exists                        
+    H5E_FILEOPEN,               # file already open                          
+    H5E_CANTCREATE,             # Can't create file                          
+    H5E_CANTOPENFILE,           # Can't open file                            
+    H5E_CANTCLOSEFILE,          # Can't close file                 
+    H5E_NOTHDF5,                # not an HDF5 format file                    
+    H5E_BADFILE,                # bad file ID accessed                       
+    H5E_TRUNCATED,              # file has been truncated                    
+    H5E_MOUNT,                    # file mount error                 
+
+    #  Generic low-level file I/O errors
+    H5E_SEEKERROR,              # seek failed                                
+    H5E_READERROR,              # read failed                                
+    H5E_WRITEERROR,             # write failed                               
+    H5E_CLOSEERROR,             # close failed                               
+    H5E_OVERFLOW,                # address overflowed                 
+    H5E_FCNTL,                  # file fcntl failed                          
+
+    #  Function entry/exit interface errors 
+    H5E_CANTINIT,               # Can't initialize object                    
+    H5E_ALREADYINIT,            # object already initialized                 
+    H5E_CANTRELEASE,            # Can't release object                       
+
+    #  Object atom related errors 
+    H5E_BADATOM,                # Can't find atom information                
+    H5E_BADGROUP,               # Can't find group information               
+    H5E_CANTREGISTER,           # Can't register new atom                    
+    H5E_CANTINC,                # Can't increment reference count            
+    H5E_CANTDEC,                # Can't decrement reference count            
+    H5E_NOIDS,                  # Out of IDs for group                       
+
+    #  Cache related errors 
+    H5E_CANTFLUSH,              # Can't flush object from cache              
+    H5E_CANTSERIALIZE,          # Unable to serialize data from cache        
+    H5E_CANTLOAD,               # Can't load object into cache               
+    H5E_PROTECT,                # protected object error                     
+    H5E_NOTCACHED,              # object not currently cached                
+    H5E_SYSTEM,                 # Internal error detected                    
+    H5E_CANTINS,                # Unable to insert metadata into cache       
+    H5E_CANTRENAME,             # Unable to rename metadata                  
+    H5E_CANTPROTECT,            # Unable to protect metadata                 
+    H5E_CANTUNPROTECT,          # Unable to unprotect metadata               
+
+    #  B-tree related errors 
+    H5E_NOTFOUND,               # object not found                           
+    H5E_EXISTS,                 # object already exists                      
+    H5E_CANTENCODE,             # Can't encode value                         
+    H5E_CANTDECODE,             # Can't decode value                         
+    H5E_CANTSPLIT,              # Can't split node                           
+    H5E_CANTINSERT,             # Can't insert object                        
+    H5E_CANTLIST,               # Can't list node                            
+
+    #  Object header related errors 
+    H5E_LINKCOUNT,              # bad object header link count               
+    H5E_VERSION,                # wrong version number                       
+    H5E_ALIGNMENT,              # alignment error                            
+    H5E_BADMESG,                # unrecognized message                       
+    H5E_CANTDELETE,             #  Can't delete message                      
+    H5E_BADITER,                #  Iteration failed                          
+
+    #  Group related errors 
+    H5E_CANTOPENOBJ,            # Can't open object                          
+    H5E_CANTCLOSEOBJ,           # Can't close object                         
+    H5E_COMPLEN,                # name component is too long                 
+    H5E_LINK,                   # link count failure                         
+    H5E_SLINK,                    # symbolic link error                 
+    H5E_PATH,                    # Problem with path to object             
+
+    #  Datatype conversion errors 
+    H5E_CANTCONVERT,            # Can't convert datatypes  TypeError?
+    H5E_BADSIZE,                # Bad size for object                        
+
+    #  Dataspace errors 
+    H5E_CANTCLIP,               # Can't clip hyperslab region                
+    H5E_CANTCOUNT,              # Can't count elements                       
+    H5E_CANTSELECT,             # Can't select hyperslab                     
+    H5E_CANTNEXT,               # Can't move to next iterator location       
+    H5E_BADSELECT,              # Invalid selection                          
+    H5E_CANTCOMPARE,            # Can't compare objects                      
+
+    #  Property list errors 
+    H5E_CANTGET,                # Can't get value                            
+    H5E_CANTSET,                # Can't set value                            
+    H5E_DUPCLASS,               # Duplicate class name in parent class       
+
+    #  Parallel errors 
+    H5E_MPI,                    # some MPI function failed             
+    H5E_MPIERRSTR,                # MPI Error String                  
+
+    #  Heap errors 
+    H5E_CANTRESTORE,            # Can't restore condition                    
+
+    #  TBBT errors 
+    H5E_CANTMAKETREE,            # Can't create TBBT tree                     
+
+    #  I/O pipeline errors 
+    H5E_NOFILTER,               # requested filter is not available          
+    H5E_CALLBACK,               # callback failed                            
+    H5E_CANAPPLY,               # error from filter "can apply" callback     
+    H5E_SETLOCAL,               # error from filter "set local" callback     
+    H5E_NOENCODER,              #  Filter present, but encoding disabled     
+
+    #  System level errors 
+    H5E_SYSERRSTR               #  System error message                 
+
+  cdef enum H5E_direction_t:
+    H5E_WALK_UPWARD    = 0  # begin deep, end at API function    
+    H5E_WALK_DOWNWARD = 1   # begin at API function, end deep    
+
+  ctypedef struct H5E_error_t:
+    H5E_major_t     maj_num        #  major error number             
+    H5E_minor_t     min_num        #  minor error number             
+    char    *func_name      #  function in which error occurred   
+    char    *file_name      #  file in which error occurred       
+    unsigned    line        #  line in file where error occurs    
+    char    *desc           #  optional supplied description      
+
+  # --- Error handling --------------------------------------------------------
+
+
+  char      *H5Eget_major(H5E_major_t n)
+  char      *H5Eget_minor(H5E_minor_t n)
+  herr_t    H5Eclear() except *
+  ctypedef herr_t (*H5E_auto_t)(void *client_data)
+  herr_t    H5Eset_auto(H5E_auto_t func, void *client_data)
+  herr_t    H5Eget_auto(H5E_auto_t *func, void** client_data)
+  ctypedef herr_t (*H5E_walk_t)(int n, H5E_error_t *err_desc, void* client_data)  
+  herr_t    H5Ewalk(H5E_direction_t direction, H5E_walk_t func, void* client_data  )
+
+# === Custom C extensions =====================================================
+
+ctypedef H5E_auto_t err_c
+cdef int _enable_exceptions() except -1
+cdef int _disable_exceptions() except -1
+
+cdef err_c pause_errors() except? NULL
+cdef int resume_errors(err_c cookie) except -1
+
 # === Custom identifier wrappers ==============================================
 
 cdef class ObjectID:
     """ Base wrapper class for HDF5 object identifiers """
     cdef readonly hid_t id
-
-cdef class LockableID(ObjectID):
     cdef readonly int _locked
 
 
diff --git a/h5py/h5.pyx b/h5py/h5.pyx
index a0aa1ca..11d7052 100644
--- a/h5py/h5.pyx
+++ b/h5py/h5.pyx
@@ -18,8 +18,7 @@
     - HDF5_VERS, HDF5_VERS_TPL:  Library version
     - API_VERS, API_VERS_TPL:  API version (1.6 or 1.8) used to compile h5py.
 """
-
-
+from python cimport PyErr_SetObject
 
 # === API =====================================================================
 
@@ -37,16 +36,9 @@ def get_libversion():
 
     return (major, minor, release)
     
-#: HDF5 library version as a 3-tuple (major, minor, release), e.g. (1,6,5)
 HDF5_VERS_TPL = get_libversion()        
-
-#: HDF5 library version as a string "major.minor.release", e.g. "1.6.5"
 HDF5_VERS = "%d.%d.%d" % HDF5_VERS_TPL
-
-#: API version used to compile, as a string "major.minor", e.g. "1.6"
 API_VERS = '1.6'
-
-#: API version used to compile, as a 2-tuple (major, minor), e.g. (1,6)
 API_VERS_TPL = (1,6)
 
 
@@ -62,17 +54,19 @@ cdef class ObjectID:
         
     def __cinit__(self, hid_t id):
         """ Object init; simply records the given ID. """
+        self._locked = 0
         self.id = id
 
     def __dealloc__(self):
         """ Automatically decrefs the ID, if it's valid. """
-        if H5Iget_type(self.id) != H5I_BADID:
+        if (not self._locked) and (H5Iget_type(self.id) != H5I_BADID):
             H5Idec_ref(self.id)
 
     def __copy__(self):
         """ Create a new instance and incref the ID. """
         copy = type(self)(self.id)
-        H5Iinc_ref(self.id)
+        if not self._locked:
+            H5Iinc_ref(self.id)
         return copy
 
     def __str__(self):
@@ -80,30 +74,394 @@ cdef class ObjectID:
             ref = str(H5Iget_ref(self.id))
         else:
             ref = "INVALID"
+        if self._locked:
+            lstr = "locked"
+        else:
+            lstr = "unlocked"
 
-        return "%d [%s] %s" % (self.id, ref, self.__class__.__name__)
+        return "%d [%s] (%s) %s" % (self.id, ref, lstr, self.__class__.__name__)
 
-cdef class LockableID(ObjectID):
+# === Automatic error handling ================================================
 
-    def __dealloc__(self):
-        if not self._locked and H5Iget_type(self.id) != H5I_BADID:
-            H5Idec_ref(self.id)
 
-    def __copy__(self):
-        return type(self)(self.id)
+# === Public exception hierarchy ==============================================
+
+class H5Error(EnvironmentError):
+    """ Base class for internal HDF5 library exceptions.
+        Subclass of EnvironmentError; errno is computed from the HDF5 major
+        and minor error numbers:
+            1000*(major number) + minor number
+    """
+    pass
+
+# --- New classes -------------------------------------------------------------
+
+           
+#    H5E_ARGS,                   # invalid arguments to routine
+class ArgsError(H5Error):
+    """ H5E_ARGS """
+    pass
+        
+#    H5E_RESOURCE,               # resource unavailable   
+class ResourceError(H5Error):
+    """ H5E_RESOURCE """
+    pass
+                    
+#   H5E_INTERNAL,               #  Internal error (too specific to document)
+class InternalError(H5Error):
+    """ H5E_INTERNAL """
+    pass
+
+#    H5E_FILE,                   # file Accessability       
+class FileError(H5Error):
+    """ H5E_FILE """
+    pass
+                  
+#    H5E_IO,                     # Low-level I/O                      
+class LowLevelIOError(H5Error):
+    """ H5E_IO """
+    pass
+        
+#    H5E_FUNC,                   # function Entry/Exit     
+class FuncError(H5Error):
+    """ H5E_FUNC """
+    pass
+                   
+#    H5E_ATOM,                   # object Atom         
+class AtomError(H5Error):
+    """ H5E_ATOM """
+    pass
+                       
+#   H5E_CACHE,                  # object Cache        
+class CacheError(H5Error):
+    """ H5E_CACHE """
+    pass
+                       
+#   H5E_BTREE,                  # B-Tree Node           
+class BtreeError(H5Error):
+    """ H5E_BTREE """
+    pass
+                     
+#    H5E_SYM,                    # symbol Table         
+class SymbolError(H5Error):
+    """ H5E_SYM """
+    pass
+                      
+#   H5E_HEAP,                   # Heap  
+class HeapError(H5Error):
+    """ H5E_HEAP """
+    pass
+                                     
+#    H5E_OHDR,                   # object Header     
+class ObjectHeaderError(H5Error):
+    """ H5E_OHDR """
+    pass
+                         
+#    H5E_DATATYPE,               # Datatype    
+class DatatypeError(H5Error):
+    """ H5E_DATATYPE """
+    pass
+                               
+#    H5E_DATASPACE,              # Dataspace                      
+class DataspaceError(H5Error):
+    """ H5E_DATASPACE """
+    pass
+            
+#    H5E_DATASET,                # Dataset                        
+class DatasetError(H5Error):
+    """ H5E_DATASET """
+    pass
+            
+#    H5E_STORAGE,                # data storage                
+class StorageError(H5Error):
+    """ H5E_STORAGE """
+    pass
+               
+#    H5E_PLIST,                  # Property lists                  
+class PropertyError(H5Error):
+    """ H5E_PLIST """
+    pass
+           
+#    H5E_ATTR,                   # Attribute     
+class AttrError(H5Error):
+    """ H5E_ATTR """
+    pass
+                             
+#    H5E_PLINE,                  # Data filters       
+class FilterError(H5Error):
+    """ H5E_PLINE """
+    pass
+                        
+#    H5E_EFL,                    # External file list                         
+class FileListError(H5Error):
+    """ H5E_EFL """
+    pass
+
+#    H5E_REFERENCE,              # References          
+class RefError(H5Error):
+    """ H5E_REFERENCE """
+    pass
+                       
+#    H5E_VFL,                    # Virtual File Layer        
+class VirtualFileError(H5Error):
+    """ H5E_VFL """
+    pass
+         
+#    H5E_TBBT,                   # Threaded, Balanced, Binary Trees         
+class TBBTError(H5Error):
+    """ H5E_TBBT """
+    pass
+  
+#    H5E_TST,                    # Ternary Search Trees                       
+class TSTError(H5Error):
+    """ H5E_TST """
+    pass
+
+#    H5E_RS,                     # Reference Counted Strings        
+class RSError(H5Error):
+    """ H5E_RS """
+    pass
+          
+#    H5E_ERROR,                  # Error API                    
+class ErrorError(H5Error):
+    """ H5E_ERROR """
+    pass
+              
+#    H5E_SLIST                   # Skip Lists        
+class SkipListError(H5Error):
+    """ H5E_SLIST """
+    pass  
+
+_exceptions = {
+    H5E_ARGS: ArgsError,
+    H5E_RESOURCE: ResourceError,
+    H5E_INTERNAL: InternalError,
+    H5E_FILE: FileError,
+    H5E_IO: LowLevelIOError,
+    H5E_FUNC: FuncError,
+    H5E_ATOM: AtomError,
+    H5E_CACHE: CacheError,
+    H5E_BTREE: BtreeError,
+    H5E_SYM: SymbolError,
+    H5E_HEAP: HeapError,
+    H5E_OHDR: ObjectHeaderError,
+    H5E_DATATYPE: DatatypeError,
+    H5E_DATASPACE: DataspaceError,
+    H5E_DATASET: DatasetError,
+    H5E_STORAGE: StorageError,
+    H5E_PLIST: PropertyError,
+    H5E_ATTR: AttrError,
+    H5E_PLINE: FilterError,
+    H5E_EFL: FileListError,
+    H5E_REFERENCE: RefError,
+    H5E_VFL: VirtualFileError,
+    H5E_TBBT: TBBTError,
+    H5E_TST: TSTError,
+    H5E_RS: RSError,
+    H5E_ERROR: ErrorError,
+    H5E_SLIST: SkipListError}
+
+# === Error stack inspection ==================================================
+
+cdef class ErrorStackElement:
+    """
+        Represents an entry in the HDF5 error stack.
+        Modeled on the H5E_error_t struct.  All parameters are read-only.
+
+        Atributes
+        maj_num:    INT major error number
+        min_num:    INT minor error number
+        func_name:  STRING name of failing function
+        file_name:  STRING name of file in which error occurreed
+        line:       UINT line number at which error occured
+        desc:       STRING description of error
+    """
+    cdef readonly int maj_num
+    cdef readonly int min_num
+    cdef readonly object func_name
+    cdef readonly object file_name
+    cdef readonly unsigned int line
+    cdef readonly object desc
 
     def __str__(self):
-        if H5Iget_type(self.id) != H5I_BADID:
-            ref = str(H5Iget_ref(self.id))
-        else:
-            ref = "INVALID"
-        if self._locked:
-            lstr = "locked"
-        else:
-            lstr = "unlocked"
+        return '%2d:%2d "%s" at %s (%s: %s)' % (self.maj_num, self.min_num,
+                self.desc, self.func_name, H5Eget_major(<H5E_major_t>self.maj_num),
+                H5Eget_minor(<H5E_minor_t>self.min_num) )
 
-        return "%d [%s] (%s) %s" % (self.id, ref, lstr, self.__class__.__name__)
+cdef herr_t walk_cb(int n, H5E_error_t *err_desc, void* stack_in):
+    # Callback function to extract elements from the HDF5 error stack
+
+    stack = <object>stack_in
+    cdef ErrorStackElement element
+
+    element = ErrorStackElement()
+    element.maj_num = err_desc.maj_num
+    element.min_num = err_desc.min_num
+    element.func_name = err_desc.func_name
+    element.file_name = err_desc.file_name
+    element.desc = err_desc.desc
+
+    stack.append(element)
+
+    return 0
 
+def error_stack():
+    """ () => LIST error_stack
+
+        Retrieve the HDF5 error stack as a list of ErrorStackElement objects,
+        with the most recent call (the deepest one) listed last.
+    """
+    stack = []
+    H5Ewalk(H5E_WALK_DOWNWARD, walk_cb, <void*>stack)
+    return stack
+
+def error_string():
+    """ () => STRING error_stack
+
+        Return a string representation of the current error condition.
+        Format is one line of the format 
+            '<Description> (<Function name>: <error type>)'
+
+        If the stack is more than one level deep, this is followed by n lines
+        of the format:
+            '    n: "<Description>" at <function name>'
+    """
+    cdef int stacklen
+    cdef ErrorStackElement el
+
+    stack = error_stack()
+    stacklen = len(stack)
+
+    if stacklen == 0:
+        msg = "Unspecified HDF5 error"
+    else:
+        el = stack[0]
+        msg = "%s (%s)" % (el.desc.capitalize(), el.func_name)
+        if stacklen > 1:
+            msg = msg + "\nHDF5 Error Stack:"
+            for i from 0<=i<stacklen:
+                #msg = msg + '\n' + str(stack[i])
+                el = stack[i]
+                msg = msg + '\n    %d: "%s" at %s' % \
+                            (i, el.desc.capitalize(), el.func_name)
+
+    return msg
+
+def clear():
+    """ ()
+
+        Clear the error stack.
+    """
+    H5Eclear()
+
+def get_major(int error):
+    """ (INT error) => STRING description
+
+        Get a description associated with an HDF5 minor error code.
+    """
+    return H5E_get_major(<H5E_major_t>error)
+
+def get_minor(int error):
+    """ (INT error) => STRING description
+
+        Get a description associated with an HDF5 minor error code.
+    """
+    return H5E_get_minor(<H5E_minor_t>error)
+
+def get_error(int error):
+    """ (INT errno) => STRING description
+
+        Get a full description for an "errno"-style HDF5 error code.
+    """
+    cdef int mj
+    cdef int mn
+    mn = error % 1000
+    mj = (error-mn)/1000
+    return "%s: %s" % (H5E_get_major(<H5E_major_t>mj), H5E_get_minor(<H5E_minor_t>mn))
+
+def split_error(int error):
+    """ (INT errno) => (INT major, INT minor)
+
+        Convenience function to split an "errno"-style HDF5 error code into
+        its major and minor components.  It's recommended you use this
+        function instead of doing it yourself, as the "encoding" may change
+        in the future.
+    """
+    cdef int mn
+    mn = error % 1000
+    return ((error-mn)/1000, mn)
+
+# === Automatic exception API =================================================
+
+cdef herr_t extract_cb(int n, H5E_error_t *err_desc, void* data_in):
+    # Callback to determine error information at top/bottom of stack
+    cdef H5E_error_t *err_struct
+    err_struct = <H5E_error_t*>data_in
+    err_struct.maj_num = err_desc.maj_num
+    err_struct.min_num = err_desc.min_num
+    return 1
+    
+cdef herr_t err_callback(void* client_data):
+    # Callback which sets Python exception based on the current error stack.
+
+    # Can't use the standard Pyrex raise because then the traceback
+    # points here!
+
+    cdef H5E_error_t err_struct
+    cdef H5E_major_t mj
+    cdef H5E_minor_t mn
+
+    # Determine the error numbers for the first entry on the stack.
+    H5Ewalk(H5E_WALK_UPWARD, extract_cb, &err_struct)
+    mj = err_struct.maj_num
+    mn = err_struct.min_num
+
+    exc = _exceptions.get(mj, H5Error)
+    if exc == ErrorError:
+        exc = H5Error
+
+    msg = error_string()
+    PyErr_SetObject(exc, (1000*mj + mn, msg))
+
+    return 1
+
+cdef int _enable_exceptions() except -1:
+    # Enable automatic exception handling, by registering the above callback
+    if H5Eset_auto(err_callback, NULL) < 0:
+        raise RuntimeError("Failed to register HDF5 exception callback.")
+    return 0
+
+cdef int _disable_exceptions() except -1:
+    # Disable automatic exception handling
+    if H5Eset_auto(NULL, NULL) < 0:
+        raise RuntimeError("Failed to unregister HDF5 exception callback.")
+    return 0
+
+cdef err_c pause_errors() except? NULL:
+    # Temporarily disable automatic exception handling, and return a cookie
+    # which can later be used to re-enable it.
+    cdef err_c cookie
+    cdef void* whatever
+    cookie = NULL
+
+    if H5Eget_auto(&cookie, &whatever) < 0:
+        raise RuntimeError("Failed to retrieve the current error handler.")
+
+    if H5Eset_auto(NULL, NULL) < 0:
+        raise RuntimeError("Failed to temporarily disable error handling.")
+
+    return cookie
+
+cdef int resume_errors(err_c cookie) except -1:
+    # Resume automatic exception handling, using a cookie from a previous
+    # call to pause_errors().  Also clears the error stack.
+    if H5Eset_auto(cookie, NULL) < 0:
+        raise RuntimeError("Failed to re-enable error handling.")
+    
+    if H5Eclear() < 0:
+        raise RuntimeError("Failed to clear error stack.")
+
+    return 0
 
 # === Library init ============================================================
 
@@ -113,6 +471,7 @@ cdef int import_hdf5() except -1:
     _enable_exceptions()
     return 0
 
+import_hdf5()
 
 
 
diff --git a/h5py/h5a.pxd b/h5py/h5a.pxd
index 5c90aab..3905792 100644
--- a/h5py/h5a.pxd
+++ b/h5py/h5a.pxd
@@ -16,9 +16,10 @@
 
 include "std_defs.pxi"
 from h5 cimport ObjectID
+from numpy cimport class ndarray
+
 cdef class AttrID(ObjectID):
     pass
-from numpy cimport class ndarray
 
 cdef extern from "hdf5.h":
 
diff --git a/h5py/h5e.pxd b/h5py/h5e.pxd
deleted file mode 100644
index edd4e9b..0000000
--- a/h5py/h5e.pxd
+++ /dev/null
@@ -1,220 +0,0 @@
-#+
-# 
-# This file is part of h5py, a low-level Python interface to the HDF5 library.
-# 
-# Copyright (C) 2008 Andrew Collette
-# http://h5py.alfven.org
-# License: BSD  (See LICENSE.txt for full license)
-# 
-# $Date$
-# 
-#-
-
-# This file contains code or comments from the HDF5 library. The complete HDF5
-# license is available in the file licenses/hdf5.txt in the distribution
-# root directory.
-
-include "std_defs.pxi"
-
-cdef extern from "hdf5.h":
-
-  # Major error numbers
-  ctypedef enum H5E_major_t:
-    H5E_NONE_MAJOR       = 0,   # special zero, no error                     
-    H5E_ARGS,                   # invalid arguments to routine               
-    H5E_RESOURCE,               # resource unavailable                       
-    H5E_INTERNAL,               #  Internal error (too specific to document)
-    H5E_FILE,                   # file Accessability                         
-    H5E_IO,                     # Low-level I/O                              
-    H5E_FUNC,                   # function Entry/Exit                        
-    H5E_ATOM,                   # object Atom                                
-    H5E_CACHE,                  # object Cache                               
-    H5E_BTREE,                  # B-Tree Node                                
-    H5E_SYM,                    # symbol Table                               
-    H5E_HEAP,                   # Heap                                       
-    H5E_OHDR,                   # object Header                              
-    H5E_DATATYPE,               # Datatype                                   
-    H5E_DATASPACE,              # Dataspace                                  
-    H5E_DATASET,                # Dataset                                    
-    H5E_STORAGE,                # data storage                               
-    H5E_PLIST,                  # Property lists                             
-    H5E_ATTR,                   # Attribute                                  
-    H5E_PLINE,                  # Data filters                               
-    H5E_EFL,                    # External file list                         
-    H5E_REFERENCE,              # References                                 
-    H5E_VFL,                    # Virtual File Layer                 
-    H5E_TBBT,                   # Threaded, Balanced, Binary Trees           
-    H5E_TST,                    # Ternary Search Trees                       
-    H5E_RS,                     # Reference Counted Strings                  
-    H5E_ERROR,                  # Error API                                  
-    H5E_SLIST                   # Skip Lists                                 
-
-  # Minor error numbers
-  ctypedef enum H5E_minor_t:
-    H5E_NONE_MINOR       = 0
-
-    #  Argument errors 
-    H5E_UNINITIALIZED,          # information is unitialized
-    H5E_UNSUPPORTED,            # feature is unsupported
-    H5E_BADTYPE,                # incorrect type found
-    H5E_BADRANGE,               # argument out of range
-    H5E_BADVALUE,               # bad value for argument
-
-    #  Resource errors 
-    H5E_NOSPACE,                # no space available for allocation
-    H5E_CANTCOPY,               # unable to copy object
-    H5E_CANTFREE,               # unable to free object
-    H5E_ALREADYEXISTS,          # Object already exists
-    H5E_CANTLOCK,               # Unable to lock object
-    H5E_CANTUNLOCK,             # Unable to unlock object
-    H5E_CANTGC,                 # Unable to garbage collect
-    H5E_CANTGETSIZE,            # Unable to compute size
-
-    #  File accessability errors 
-    H5E_FILEEXISTS,             # file already exists                        
-    H5E_FILEOPEN,               # file already open                          
-    H5E_CANTCREATE,             # Can't create file                          
-    H5E_CANTOPENFILE,           # Can't open file                            
-    H5E_CANTCLOSEFILE,          # Can't close file                 
-    H5E_NOTHDF5,                # not an HDF5 format file                    
-    H5E_BADFILE,                # bad file ID accessed                       
-    H5E_TRUNCATED,              # file has been truncated                    
-    H5E_MOUNT,                    # file mount error                 
-
-    #  Generic low-level file I/O errors
-    H5E_SEEKERROR,              # seek failed                                
-    H5E_READERROR,              # read failed                                
-    H5E_WRITEERROR,             # write failed                               
-    H5E_CLOSEERROR,             # close failed                               
-    H5E_OVERFLOW,                # address overflowed                 
-    H5E_FCNTL,                  # file fcntl failed                          
-
-    #  Function entry/exit interface errors 
-    H5E_CANTINIT,               # Can't initialize object                    
-    H5E_ALREADYINIT,            # object already initialized                 
-    H5E_CANTRELEASE,            # Can't release object                       
-
-    #  Object atom related errors 
-    H5E_BADATOM,                # Can't find atom information                
-    H5E_BADGROUP,               # Can't find group information               
-    H5E_CANTREGISTER,           # Can't register new atom                    
-    H5E_CANTINC,                # Can't increment reference count            
-    H5E_CANTDEC,                # Can't decrement reference count            
-    H5E_NOIDS,                  # Out of IDs for group                       
-
-    #  Cache related errors 
-    H5E_CANTFLUSH,              # Can't flush object from cache              
-    H5E_CANTSERIALIZE,          # Unable to serialize data from cache        
-    H5E_CANTLOAD,               # Can't load object into cache               
-    H5E_PROTECT,                # protected object error                     
-    H5E_NOTCACHED,              # object not currently cached                
-    H5E_SYSTEM,                 # Internal error detected                    
-    H5E_CANTINS,                # Unable to insert metadata into cache       
-    H5E_CANTRENAME,             # Unable to rename metadata                  
-    H5E_CANTPROTECT,            # Unable to protect metadata                 
-    H5E_CANTUNPROTECT,          # Unable to unprotect metadata               
-
-    #  B-tree related errors 
-    H5E_NOTFOUND,               # object not found                           
-    H5E_EXISTS,                 # object already exists                      
-    H5E_CANTENCODE,             # Can't encode value                         
-    H5E_CANTDECODE,             # Can't decode value                         
-    H5E_CANTSPLIT,              # Can't split node                           
-    H5E_CANTINSERT,             # Can't insert object                        
-    H5E_CANTLIST,               # Can't list node                            
-
-    #  Object header related errors 
-    H5E_LINKCOUNT,              # bad object header link count               
-    H5E_VERSION,                # wrong version number                       
-    H5E_ALIGNMENT,              # alignment error                            
-    H5E_BADMESG,                # unrecognized message                       
-    H5E_CANTDELETE,             #  Can't delete message                      
-    H5E_BADITER,                #  Iteration failed                          
-
-    #  Group related errors 
-    H5E_CANTOPENOBJ,            # Can't open object                          
-    H5E_CANTCLOSEOBJ,           # Can't close object                         
-    H5E_COMPLEN,                # name component is too long                 
-    H5E_LINK,                   # link count failure                         
-    H5E_SLINK,                    # symbolic link error                 
-    H5E_PATH,                    # Problem with path to object             
-
-    #  Datatype conversion errors 
-    H5E_CANTCONVERT,            # Can't convert datatypes  TypeError?
-    H5E_BADSIZE,                # Bad size for object                        
-
-    #  Dataspace errors 
-    H5E_CANTCLIP,               # Can't clip hyperslab region                
-    H5E_CANTCOUNT,              # Can't count elements                       
-    H5E_CANTSELECT,             # Can't select hyperslab                     
-    H5E_CANTNEXT,               # Can't move to next iterator location       
-    H5E_BADSELECT,              # Invalid selection                          
-    H5E_CANTCOMPARE,            # Can't compare objects                      
-
-    #  Property list errors 
-    H5E_CANTGET,                # Can't get value                            
-    H5E_CANTSET,                # Can't set value                            
-    H5E_DUPCLASS,               # Duplicate class name in parent class       
-
-    #  Parallel errors 
-    H5E_MPI,                    # some MPI function failed             
-    H5E_MPIERRSTR,                # MPI Error String                  
-
-    #  Heap errors 
-    H5E_CANTRESTORE,            # Can't restore condition                    
-
-    #  TBBT errors 
-    H5E_CANTMAKETREE,            # Can't create TBBT tree                     
-
-    #  I/O pipeline errors 
-    H5E_NOFILTER,               # requested filter is not available          
-    H5E_CALLBACK,               # callback failed                            
-    H5E_CANAPPLY,               # error from filter "can apply" callback     
-    H5E_SETLOCAL,               # error from filter "set local" callback     
-    H5E_NOENCODER,              #  Filter present, but encoding disabled     
-
-    #  System level errors 
-    H5E_SYSERRSTR               #  System error message                 
-
-  cdef enum H5E_direction_t:
-    H5E_WALK_UPWARD    = 0  # begin deep, end at API function    
-    H5E_WALK_DOWNWARD = 1   # begin at API function, end deep    
-
-  ctypedef struct H5E_error_t:
-    H5E_major_t     maj_num        #  major error number             
-    H5E_minor_t     min_num        #  minor error number             
-    char    *func_name      #  function in which error occurred   
-    char    *file_name      #  file in which error occurred       
-    unsigned    line        #  line in file where error occurs    
-    char    *desc           #  optional supplied description      
-
-  # --- Error handling --------------------------------------------------------
-
-
-  char      *H5Eget_major(H5E_major_t n)
-  char      *H5Eget_minor(H5E_minor_t n)
-  herr_t    H5Eclear() except *
-  ctypedef herr_t (*H5E_auto_t)(void *client_data)
-  herr_t    H5Eset_auto(H5E_auto_t func, void *client_data)
-  herr_t    H5Eget_auto(H5E_auto_t *func, void** client_data)
-  ctypedef herr_t (*H5E_walk_t)(int n, H5E_error_t *err_desc, void* client_data)  
-  herr_t    H5Ewalk(H5E_direction_t direction, H5E_walk_t func, void* client_data  )
-
-# Custom error-handling functions
-
-ctypedef H5E_auto_t err_c
-cdef int _enable_exceptions() except -1
-cdef int _disable_exceptions() except -1
-
-cdef err_c pause_errors() except? NULL
-cdef int resume_errors(err_c cookie) except -1
-
-
-
-
-
-
-
-
-
-
diff --git a/h5py/h5e.pyx b/h5py/h5e.pyx
deleted file mode 100644
index 6cb4b75..0000000
--- a/h5py/h5e.pyx
+++ /dev/null
@@ -1,406 +0,0 @@
-#+
-# 
-# This file is part of h5py, a low-level Python interface to the HDF5 library.
-# 
-# Copyright (C) 2008 Andrew Collette
-# http://h5py.alfven.org
-# License: BSD  (See LICENSE.txt for full license)
-# 
-# $Date$
-# 
-#-
-
-"""
-    Provides a Python exception hierarchy modeled on HDF5 major error numbers,
-    and exports a C interface which automatically raises exceptions when
-    an error is detected in the HDF5 library.
-
-    Each exception class is associated with an HDF5 major error number.  Since
-    the HDF5 library determines which error number is issued, it also
-    determines which exception class is raised.  The choice is occasionally
-    surprising, and not well documented in the library itself.
-"""
-
-from python cimport PyErr_SetObject
-
-# === Public exception hierarchy ==============================================
-
-class H5Error(EnvironmentError):
-    """ Base class for internal HDF5 library exceptions.
-        Subclass of EnvironmentError; errno is computed from the HDF5 major
-        and minor error numbers:
-            1000*(major number) + minor number
-    """
-    pass
-
-# --- New classes -------------------------------------------------------------
-
-           
-#    H5E_ARGS,                   # invalid arguments to routine
-class ArgsError(H5Error):
-    """ H5E_ARGS """
-    pass
-        
-#    H5E_RESOURCE,               # resource unavailable   
-class ResourceError(H5Error):
-    """ H5E_RESOURCE """
-    pass
-                    
-#   H5E_INTERNAL,               #  Internal error (too specific to document)
-class InternalError(H5Error):
-    """ H5E_INTERNAL """
-    pass
-
-#    H5E_FILE,                   # file Accessability       
-class FileError(H5Error):
-    """ H5E_FILE """
-    pass
-                  
-#    H5E_IO,                     # Low-level I/O                      
-class LowLevelIOError(H5Error):
-    """ H5E_IO """
-    pass
-        
-#    H5E_FUNC,                   # function Entry/Exit     
-class FuncError(H5Error):
-    """ H5E_FUNC """
-    pass
-                   
-#    H5E_ATOM,                   # object Atom         
-class AtomError(H5Error):
-    """ H5E_ATOM """
-    pass
-                       
-#   H5E_CACHE,                  # object Cache        
-class CacheError(H5Error):
-    """ H5E_CACHE """
-    pass
-                       
-#   H5E_BTREE,                  # B-Tree Node           
-class BtreeError(H5Error):
-    """ H5E_BTREE """
-    pass
-                     
-#    H5E_SYM,                    # symbol Table         
-class SymbolError(H5Error):
-    """ H5E_SYM """
-    pass
-                      
-#   H5E_HEAP,                   # Heap  
-class HeapError(H5Error):
-    """ H5E_HEAP """
-    pass
-                                     
-#    H5E_OHDR,                   # object Header     
-class ObjectHeaderError(H5Error):
-    """ H5E_OHDR """
-    pass
-                         
-#    H5E_DATATYPE,               # Datatype    
-class DatatypeError(H5Error):
-    """ H5E_DATATYPE """
-    pass
-                               
-#    H5E_DATASPACE,              # Dataspace                      
-class DataspaceError(H5Error):
-    """ H5E_DATASPACE """
-    pass
-            
-#    H5E_DATASET,                # Dataset                        
-class DatasetError(H5Error):
-    """ H5E_DATASET """
-    pass
-            
-#    H5E_STORAGE,                # data storage                
-class StorageError(H5Error):
-    """ H5E_STORAGE """
-    pass
-               
-#    H5E_PLIST,                  # Property lists                  
-class PropertyError(H5Error):
-    """ H5E_PLIST """
-    pass
-           
-#    H5E_ATTR,                   # Attribute     
-class AttrError(H5Error):
-    """ H5E_ATTR """
-    pass
-                             
-#    H5E_PLINE,                  # Data filters       
-class FilterError(H5Error):
-    """ H5E_PLINE """
-    pass
-                        
-#    H5E_EFL,                    # External file list                         
-class FileListError(H5Error):
-    """ H5E_EFL """
-    pass
-
-#    H5E_REFERENCE,              # References          
-class RefError(H5Error):
-    """ H5E_REFERENCE """
-    pass
-                       
-#    H5E_VFL,                    # Virtual File Layer        
-class VirtualFileError(H5Error):
-    """ H5E_VFL """
-    pass
-         
-#    H5E_TBBT,                   # Threaded, Balanced, Binary Trees         
-class TBBTError(H5Error):
-    """ H5E_TBBT """
-    pass
-  
-#    H5E_TST,                    # Ternary Search Trees                       
-class TSTError(H5Error):
-    """ H5E_TST """
-    pass
-
-#    H5E_RS,                     # Reference Counted Strings        
-class RSError(H5Error):
-    """ H5E_RS """
-    pass
-          
-#    H5E_ERROR,                  # Error API                    
-class ErrorError(H5Error):
-    """ H5E_ERROR """
-    pass
-              
-#    H5E_SLIST                   # Skip Lists        
-class SkipListError(H5Error):
-    """ H5E_SLIST """
-    pass  
-
-_exceptions = {
-    H5E_ARGS: ArgsError,
-    H5E_RESOURCE: ResourceError,
-    H5E_INTERNAL: InternalError,
-    H5E_FILE: FileError,
-    H5E_IO: LowLevelIOError,
-    H5E_FUNC: FuncError,
-    H5E_ATOM: AtomError,
-    H5E_CACHE: CacheError,
-    H5E_BTREE: BtreeError,
-    H5E_SYM: SymbolError,
-    H5E_HEAP: HeapError,
-    H5E_OHDR: ObjectHeaderError,
-    H5E_DATATYPE: DatatypeError,
-    H5E_DATASPACE: DataspaceError,
-    H5E_DATASET: DatasetError,
-    H5E_STORAGE: StorageError,
-    H5E_PLIST: PropertyError,
-    H5E_ATTR: AttrError,
-    H5E_PLINE: FilterError,
-    H5E_EFL: FileListError,
-    H5E_REFERENCE: RefError,
-    H5E_VFL: VirtualFileError,
-    H5E_TBBT: TBBTError,
-    H5E_TST: TSTError,
-    H5E_RS: RSError,
-    H5E_ERROR: ErrorError,
-    H5E_SLIST: SkipListError}
-
-# === Error stack inspection ==================================================
-
-cdef class ErrorStackElement:
-    """
-        Represents an entry in the HDF5 error stack.
-        Modeled on the H5E_error_t struct.  All parameters are read-only.
-
-        Atributes
-        maj_num:    INT major error number
-        min_num:    INT minor error number
-        func_name:  STRING name of failing function
-        file_name:  STRING name of file in which error occurreed
-        line:       UINT line number at which error occured
-        desc:       STRING description of error
-    """
-    cdef readonly int maj_num
-    cdef readonly int min_num
-    cdef readonly object func_name
-    cdef readonly object file_name
-    cdef readonly unsigned int line
-    cdef readonly object desc
-
-    def __str__(self):
-        return '%2d:%2d "%s" at %s (%s: %s)' % (self.maj_num, self.min_num,
-                self.desc, self.func_name, H5Eget_major(<H5E_major_t>self.maj_num),
-                H5Eget_minor(<H5E_minor_t>self.min_num) )
-
-cdef herr_t walk_cb(int n, H5E_error_t *err_desc, void* stack_in):
-    # Callback function to extract elements from the HDF5 error stack
-
-    stack = <object>stack_in
-    cdef ErrorStackElement element
-
-    element = ErrorStackElement()
-    element.maj_num = err_desc.maj_num
-    element.min_num = err_desc.min_num
-    element.func_name = err_desc.func_name
-    element.file_name = err_desc.file_name
-    element.desc = err_desc.desc
-
-    stack.append(element)
-
-    return 0
-
-def error_stack():
-    """ () => LIST error_stack
-
-        Retrieve the HDF5 error stack as a list of ErrorStackElement objects,
-        with the most recent call (the deepest one) listed last.
-    """
-    stack = []
-    H5Ewalk(H5E_WALK_DOWNWARD, walk_cb, <void*>stack)
-    return stack
-
-def error_string():
-    """ () => STRING error_stack
-
-        Return a string representation of the current error condition.
-        Format is one line of the format 
-            '<Description> (<Function name>: <error type>)'
-
-        If the stack is more than one level deep, this is followed by n lines
-        of the format:
-            '    n: "<Description>" at <function name>'
-    """
-    cdef int stacklen
-    cdef ErrorStackElement el
-
-    stack = error_stack()
-    stacklen = len(stack)
-
-    if stacklen == 0:
-        msg = "Unspecified HDF5 error"
-    else:
-        el = stack[0]
-        msg = "%s (%s)" % (el.desc.capitalize(), el.func_name)
-        if stacklen > 1:
-            msg = msg + "\nHDF5 Error Stack:"
-            for i from 0<=i<stacklen:
-                #msg = msg + '\n' + str(stack[i])
-                el = stack[i]
-                msg = msg + '\n    %d: "%s" at %s' % \
-                            (i, el.desc.capitalize(), el.func_name)
-
-    return msg
-
-def clear():
-    """ ()
-
-        Clear the error stack.
-    """
-    H5Eclear()
-
-def get_major(int error):
-    """ (INT error) => STRING description
-
-        Get a description associated with an HDF5 minor error code.
-    """
-    return H5E_get_major(<H5E_major_t>error)
-
-def get_minor(int error):
-    """ (INT error) => STRING description
-
-        Get a description associated with an HDF5 minor error code.
-    """
-    return H5E_get_minor(<H5E_minor_t>error)
-
-def get_error(int error):
-    """ (INT errno) => STRING description
-
-        Get a full description for an "errno"-style HDF5 error code.
-    """
-    cdef int mj
-    cdef int mn
-    mn = error % 1000
-    mj = (error-mn)/1000
-    return "%s: %s" % (H5E_get_major(<H5E_major_t>mj), H5E_get_minor(<H5E_minor_t>mn))
-
-def split_error(int error):
-    """ (INT errno) => (INT major, INT minor)
-
-        Convenience function to split an "errno"-style HDF5 error code into
-        its major and minor components.  It's recommended you use this
-        function instead of doing it yourself, as the "encoding" may change
-        in the future.
-    """
-    cdef int mn
-    mn = error % 1000
-    return ((error-mn)/1000, mn)
-
-# === Automatic exception API =================================================
-
-cdef herr_t extract_cb(int n, H5E_error_t *err_desc, void* data_in):
-    # Callback to determine error information at top/bottom of stack
-    cdef H5E_error_t *err_struct
-    err_struct = <H5E_error_t*>data_in
-    err_struct.maj_num = err_desc.maj_num
-    err_struct.min_num = err_desc.min_num
-    return 1
-    
-cdef herr_t err_callback(void* client_data):
-    # Callback which sets Python exception based on the current error stack.
-
-    # Can't use the standard Pyrex raise because then the traceback
-    # points here!
-
-    cdef H5E_error_t err_struct
-    cdef H5E_major_t mj
-    cdef H5E_minor_t mn
-
-    # Determine the error numbers for the first entry on the stack.
-    H5Ewalk(H5E_WALK_UPWARD, extract_cb, &err_struct)
-    mj = err_struct.maj_num
-    mn = err_struct.min_num
-
-    exc = _exceptions.get(mj, H5Error)
-    msg = error_string()
-    PyErr_SetObject(exc, (1000*mj + mn, msg))
-
-    return 1
-
-cdef int _enable_exceptions() except -1:
-    # Enable automatic exception handling, by registering the above callback
-    if H5Eset_auto(err_callback, NULL) < 0:
-        raise RuntimeError("Failed to register HDF5 exception callback.")
-    return 0
-
-cdef int _disable_exceptions() except -1:
-    # Disable automatic exception handling
-    if H5Eset_auto(NULL, NULL) < 0:
-        raise RuntimeError("Failed to unregister HDF5 exception callback.")
-    return 0
-
-cdef err_c pause_errors() except? NULL:
-    # Temporarily disable automatic exception handling, and return a cookie
-    # which can later be used to re-enable it.
-    cdef err_c cookie
-    cdef void* whatever
-    cookie = NULL
-
-    if H5Eget_auto(&cookie, &whatever) < 0:
-        raise RuntimeError("Failed to retrieve the current error handler.")
-
-    if H5Eset_auto(NULL, NULL) < 0:
-        raise RuntimeError("Failed to temporarily disable error handling.")
-
-    return cookie
-
-cdef int resume_errors(err_c cookie) except -1:
-    # Resume automatic exception handling, using a cookie from a previous
-    # call to pause_errors().  Also clears the error stack.
-    if H5Eset_auto(cookie, NULL) < 0:
-        raise RuntimeError("Failed to re-enable error handling.")
-    
-    if H5Eclear() < 0:
-        raise RuntimeError("Failed to clear error stack.")
-
-    return 0
-
-
-
-
-
-
diff --git a/h5py/h5g.pyx b/h5py/h5g.pyx
index 082d135..a51d611 100644
--- a/h5py/h5g.pyx
+++ b/h5py/h5g.pyx
@@ -19,8 +19,7 @@ from utils cimport emalloc, efree
 
 # Runtime imports
 import h5
-from h5 import DDict
-from h5e import H5Error
+from h5 import DDict, H5Error
 
 # === Public constants and data structures ====================================
 
diff --git a/h5py/h5i.pxd b/h5py/h5i.pxd
index ad142d7..15df417 100644
--- a/h5py/h5i.pxd
+++ b/h5py/h5i.pxd
@@ -16,7 +16,7 @@
 
 include "std_defs.pxi"
 from h5 cimport class ObjectID
-from h5f cimport class FileID
+#from h5f cimport class FileID
 
 cdef extern from "hdf5.h":
 
diff --git a/h5py/h5i.pyx b/h5py/h5i.pyx
index a10f03d..67e163b 100644
--- a/h5py/h5i.pyx
+++ b/h5py/h5i.pyx
@@ -80,7 +80,7 @@ def get_file_id(ObjectID obj not None):
         Obtain an identifier for the file in which this object resides,
         re-opening the file if necessary.
     """
-    return FileID(H5Iget_file_id(obj.id))
+    return ObjectID(H5Iget_file_id(obj.id))
 
 def inc_ref(ObjectID obj not None):
     """ (ObjectID obj)
diff --git a/h5py/h5p.pyx b/h5py/h5p.pyx
index f69244c..4469bb1 100644
--- a/h5py/h5p.pyx
+++ b/h5py/h5p.pyx
@@ -16,8 +16,6 @@
 """
 
 # Pyrex compile-time imports
-from h5d cimport H5D_layout_t
-from h5z cimport H5Z_filter_t
 
 from utils cimport  require_tuple, convert_dims, convert_tuple, \
                     emalloc, efree, pybool
@@ -27,17 +25,24 @@ import h5
 import h5t
 from h5 import DDict
 
+cdef object lockid(hid_t id_in):
+    cdef PropClassID pid
+    pid = PropClassID(id_in)
+    pid._locked = 1
+    return pid
+
 # === Public constants and data structures ====================================
 
 # Property list classes
-NO_CLASS       = PropImmutableClassID(H5P_NO_CLASS)
-FILE_CREATE    = PropImmutableClassID(H5P_FILE_CREATE)
-FILE_ACCESS    = PropImmutableClassID(H5P_FILE_ACCESS)
-DATASET_CREATE = PropImmutableClassID(H5P_DATASET_CREATE)
-DATASET_XFER   = PropImmutableClassID(H5P_DATASET_XFER)
-MOUNT          = PropImmutableClassID(H5P_MOUNT)
+# These need to be locked, as the library won't let you close them.
+NO_CLASS       = lockid(H5P_NO_CLASS)
+FILE_CREATE    = lockid(H5P_FILE_CREATE)
+FILE_ACCESS    = lockid(H5P_FILE_ACCESS)
+DATASET_CREATE = lockid(H5P_DATASET_CREATE)
+DATASET_XFER   = lockid(H5P_DATASET_XFER)
+MOUNT          = lockid(H5P_MOUNT)
 
-DEFAULT = PropID(H5P_DEFAULT)
+DEFAULT = lockid(H5P_DEFAULT)  # really 0 but whatever
 
 _classmapper = { H5P_FILE_CREATE: PropFCID,
                  H5P_FILE_ACCESS: PropFAID,
@@ -66,17 +71,6 @@ cdef class PropID(ObjectID):
 cdef class PropClassID(PropID):
     pass
 
-cdef class PropImmutableClassID(PropClassID):
-
-    """
-        Represents property list class objects.
-        These are not automatically closed.
-        This is a hack until custom classes can be implemented.
-    """
-
-    def __dealloc__(self):
-        pass
-
 # === Property list HDF5 instances ============================================
 
 def create(PropClassID cls not None):
diff --git a/h5py/h5t.pxd b/h5py/h5t.pxd
index 96e2039..72d75e5 100644
--- a/h5py/h5t.pxd
+++ b/h5py/h5t.pxd
@@ -15,9 +15,9 @@
 # directory.
 
 include "std_defs.pxi"
-from h5 cimport class ObjectID, class LockableID
+from h5 cimport class ObjectID
 
-cdef class TypeID(LockableID):
+cdef class TypeID(ObjectID):
 
     cdef int enum_convert(self, long long *buf, int reverse) except -1
  
diff --git a/h5py/h5t.pyx b/h5py/h5t.pyx
index 7368060..244e1f4 100644
--- a/h5py/h5t.pyx
+++ b/h5py/h5t.pyx
@@ -66,7 +66,7 @@
 # Pyrex compile-time imports
 from defs_c cimport free
 from h5p cimport H5P_DEFAULT
-from h5e cimport err_c, pause_errors, resume_errors
+from h5 cimport err_c, pause_errors, resume_errors
 from numpy cimport dtype, ndarray
 
 from utils cimport  emalloc, efree, pybool, \
@@ -75,8 +75,7 @@ from utils cimport  emalloc, efree, pybool, \
 
 # Runtime imports
 import h5
-from h5 import DDict
-from h5e import ArgsError
+from h5 import DDict, ArgsError
 import sys
 
 # === Custom C API ============================================================
@@ -191,6 +190,10 @@ def create(int classtype, size_t size):
         Create a new HDF5 type object.  Legal values are 
         COMPOUND, OPAQUE, and ENUM.
     """
+    # If it's not one of these, the library SEGFAULTS. Thanks, guys.
+    if classtype != H5T_COMPOUND and classtype != H5T_OPAQUE and \
+        classtype != H5T_ENUM:
+        raise ValueError("Class must be COMPOUND, OPAQUE or ENUM")
     return TypeID(H5Tcreate(<H5T_class_t>classtype, size))
 
 def open(ObjectID group not None, char* name):
@@ -230,7 +233,7 @@ def enum_create(TypeID base not None):
 
 # === XXXX ====
 
-cdef class TypeID(LockableID):
+cdef class TypeID(ObjectID):
 
     """
         Represents an HDF5 datatype identifier.
diff --git a/setup.py b/setup.py
index 81e7c76..cb18812 100644
--- a/setup.py
+++ b/setup.py
@@ -190,7 +190,7 @@ except ImportError:
 ext_exten = '.pyx'
 
 # Pyrex extension modules
-pyx_modules = ['h5e', 'h5' , 'h5f', 'h5g', 'h5s', 'h5t',  
+pyx_modules = ['h5' , 'h5f', 'h5g', 'h5s', 'h5t',  
                'h5d', 'h5a', 'h5p', 'h5z', 'h5i', 'h5r', 'utils']
 
 pyx_src_path = 'h5py'

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/h5py.git



More information about the debian-science-commits mailing list