[h5py] 137/455: Fix atexit glitch, segfault in diag mode, test command class, more additions

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:26 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 9378069e1b1faf4f4ac797551c2b67bd45845481
Author: andrewcollette <andrew.collette at gmail.com>
Date:   Thu Oct 16 01:56:07 2008 +0000

    Fix atexit glitch, segfault in diag mode, test command class, more additions
---
 h5py/h5.pyx            | 34 +++++++++++++----------
 h5py/h5a.pyx           |  4 +--
 h5py/h5d.pyx           |  3 +-
 h5py/h5f.pyx           |  9 ++++++
 h5py/h5fd.pyx          |  2 +-
 h5py/h5l.pyx           | 75 +++++++++++++++++++++++++-------------------------
 h5py/h5t.pyx           |  2 +-
 h5py/tests/test_h5d.py |  1 -
 setup.py               | 27 +++++++++---------
 9 files changed, 86 insertions(+), 71 deletions(-)

diff --git a/h5py/h5.pyx b/h5py/h5.pyx
index 4b5801c..68fac6e 100644
--- a/h5py/h5.pyx
+++ b/h5py/h5.pyx
@@ -19,14 +19,14 @@
 
     Useful things defined here:
     
-      version               String with h5py version (e.g. "0.2.0")
-      version_tuple         3-tuple with h5py version (e.g. (0, 2, 0))
+    version               String with h5py version (e.g. "0.2.0")
+    version_tuple         3-tuple with h5py version (e.g. (0, 2, 0))
 
-      hdf5_version:         String with library version (e.g. "1.6.5")
-      hdf5_version_tuple:   3-tuple form of the version (e.g. (1,6,5))
+    hdf5_version:         String with library version (e.g. "1.6.5")
+    hdf5_version_tuple:   3-tuple form of the version (e.g. (1,6,5))
 
-      api_version:          String form of the API used (e.g. "1.6")
-      api_version_tuple:    2-tuple form of the version (e.g. (1,6))
+    api_version:          String form of the API used (e.g. "1.6")
+    api_version_tuple:    2-tuple form of the version (e.g. (1,6))
 
     All exception classes and error handling functions are also in this module.
 """
@@ -78,8 +78,7 @@ cdef class SmartStruct:
     def __repr__(self):
         """ Prints a header followed by a list of public property values """
         ostr = "=== %s ===\n%s"
-        attrnames = [x[0] for x in inspect.getmembers(self) if not x[0].startswith('_')]
-        attrstring = "\n".join(["%s: %s" % (x, getattr(self, x)) for x in attrnames])
+        attrstring = ["%s: %s" % x for x in inspect.getmembers(self) if not x[0].startswith('_')]
         ostr %= (self.__class__.__name__, attrstring)
         return ostr
 
@@ -172,6 +171,9 @@ cdef class PHIL:
         extension modules.  Therefore, in threading mode all routines
         acquire this lock first.  When h5py is built without thread awareness,
         all locking methods are no-ops.
+
+        This object supports the context manager protocol ("with" statement)
+        in addition to the methods acquire() and release().
     """
 
     IF H5PY_THREADS:
@@ -207,6 +209,7 @@ cdef PHIL phil = PHIL()
 
 cpdef PHIL get_phil():
     """ Obtain a reference to the PHIL. """
+    global phil
     return phil
 
 # Everything required for the decorator is now defined
@@ -255,7 +258,9 @@ cdef class ObjectID:
         """ Object init; simply records the given ID. """
         self._locked = 0
         self.id = id_
-        IF H5PY_DEBUG:
+
+    IF H5PY_DEBUG:
+        def __init__(self, hid_t id_):
             log_ident.debug("+ %s" % str(self))
 
     def __dealloc__(self):
@@ -301,7 +306,7 @@ cdef class ObjectID:
         if how != 2 and how != 3:
             return NotImplemented
 
-        if isinstance(other, ObjectID) and type(self) == type(other):
+        if isinstance(other, type(self)):
             try:
                 truthval = hash(self) == hash(other)
             except TypeError:
@@ -667,7 +672,6 @@ cdef herr_t err_callback(void* client_data) with gil:
 
 # === Library init ============================================================
 
- at sync
 def _exithack():
     """ Internal function; do not call unless you want to lose all your data.
     """
@@ -675,6 +679,9 @@ def _exithack():
     # it freaks out and dumps a message to stderr.  So we have Python dec_ref
     # everything when the interpreter's about to exit.
 
+    IF H5PY_DEBUG:
+        log_lib.info("* h5py is shutting down")
+
     cdef int count
     cdef int i
     cdef hid_t *objs
@@ -691,10 +698,10 @@ def _exithack():
         finally:
             free(objs)
 
-cdef int hdf5_inited = 0
+hdf5_inited = 0
 
 cdef int init_hdf5() except -1:
-    # Initialize the library and set register Python callbacks for exception
+    # Initialize the library and register Python callbacks for exception
     # handling.  Safe to call more than once.
     global hdf5_inited
 
@@ -727,4 +734,3 @@ version_tuple = tuple([int(x) for x in version.split('.')])
 
 
 
-
diff --git a/h5py/h5a.pyx b/h5py/h5a.pyx
index 3fcbd4b..b67d4b8 100644
--- a/h5py/h5a.pyx
+++ b/h5py/h5a.pyx
@@ -26,8 +26,8 @@ from numpy cimport import_array, ndarray, PyArray_DATA
 from utils cimport check_numpy_read, check_numpy_write, emalloc, efree
 
 # Initialization
-init_hdf5()
 import_array()
+init_hdf5()
 
 
 # === General attribute operations ============================================
@@ -209,7 +209,7 @@ def iterate(ObjectID loc not None, object func, int index=0):
     iteration and returns that value.
 
     Tip: To make your code forward-compatible with later versions of this
-    function (which supply more information to the callback), add an
+    function (which supply more arguments to the callback), add an
     additional *args parameter.
     """
     if index < 0:
diff --git a/h5py/h5d.pyx b/h5py/h5d.pyx
index 8b3f97c..3cec5ab 100644
--- a/h5py/h5d.pyx
+++ b/h5py/h5d.pyx
@@ -13,7 +13,6 @@
 """
     Provides access to the low-level HDF5 "H5D" dataset interface.
 """
-
 include "config.pxi"
 include "sync.pxi"
 
@@ -27,8 +26,8 @@ from h5s cimport SpaceID
 from h5p cimport PropID, propwrap, pdefault
 
 # Initialization
-init_hdf5()
 import_array()
+init_hdf5()
 
 # === Public constants and data structures ====================================
 
diff --git a/h5py/h5f.pyx b/h5py/h5f.pyx
index 577b356..541b5de 100644
--- a/h5py/h5f.pyx
+++ b/h5py/h5f.pyx
@@ -60,6 +60,9 @@ def open(char* name, unsigned int flags=H5F_ACC_RDWR, PropFAID fapl=None):
         Open an existing HDF5 file.  Keyword "flags" may be ACC_RWDR or
         ACC_RDONLY.  Keyword fapl may be a file access property list.
     """
+    IF H5PY_DEBUG:
+        import logging
+        logging.getLogger('h5py.library').info('* Opening file %s' % name)
     return FileID(H5Fopen(name, flags, pdefault(fapl)))
 
 @sync
@@ -76,6 +79,9 @@ def create(char* name, int flags=H5F_ACC_TRUNC, PropFCID fcpl=None,
         To keep the behavior in line with that of Python's built-in functions,
         the default is ACC_TRUNC.  Be careful!
     """
+    IF H5PY_DEBUG:
+        import logging
+        logging.getLogger('h5py.library').info('* Creating file %s' % name)
     return FileID(H5Fcreate(name, flags, pdefault(fcpl), pdefault(fapl)))
 
 @sync
@@ -238,6 +244,9 @@ cdef class FileID(ObjectID):
             physical file might not be closed until all remaining open
             identifiers are freed.  
         """
+        IF H5PY_DEBUG:
+            import logging
+            logging.getLogger('h5py.library').info('* Closing file %s' % self.name)
         H5Fclose(self.id)
 
     @sync
diff --git a/h5py/h5fd.pyx b/h5py/h5fd.pyx
index 24aa7bc..b76313e 100644
--- a/h5py/h5fd.pyx
+++ b/h5py/h5fd.pyx
@@ -12,7 +12,7 @@
 
 # This file contains code or comments from the HDF5 library.  See the file
 # licenses/hdf5.txt for the full HDF5 software license.
-
+print 'FD'
 include "config.pxi"
 include "sync.pxi"
 
diff --git a/h5py/h5l.pyx b/h5py/h5l.pyx
index 08f3517..822ee91 100644
--- a/h5py/h5l.pyx
+++ b/h5py/h5l.pyx
@@ -130,10 +130,10 @@ cdef class LinkProxy(ObjectID):
     def create_hard(self, char* new_name, GroupID cur_loc not None,
         char* cur_name, PropID lcpl=None, PropID lapl=None):
         """ (STRING new_name, GroupID cur_loc, STRING cur_name,
-             PropLCID lcpl=None, PropLAID lapl=None)
+        PropID lcpl=None, PropID lapl=None)
 
-            Create a new hard link in this group pointing to an existing link
-            in another group.
+        Create a new hard link in this group pointing to an existing link
+        in another group.
         """
         H5Lcreate_hard(cur_loc.id, cur_name, self.id, new_name,
             pdefault(lcpl), pdefault(lapl))
@@ -141,21 +141,31 @@ cdef class LinkProxy(ObjectID):
     @sync
     def create_soft(self, char* new_name, char* target,
         PropID lcpl=None, PropID lapl=None):
-        """ (STRING new_name, STRING target, PropLCID lcpl=None,
-             PropLAID lapl=None)
+        """(STRING new_name, STRING target, PropID lcpl=None, PropID lapl=None)
 
-            Create a new soft link in this group, with the given string value.
-            The link target does not need to exist.
+        Create a new soft link in this group, with the given string value.
+        The link target does not need to exist.
         """
         H5Lcreate_soft(target, self.id, new_name,
             pdefault(lcpl), pdefault(lapl))
 
     @sync
+    def create_external(self, char* link_name, char* file_name, char* obj_name,
+        PropID lcpl=None, PropID lapl=None):
+        """(STRING link_name, STRING file_name, STRING obj_name,
+        PropLCID lcpl=None, PropLAID lapl=None)
+
+        Create a new external link, pointing to an object in another file.
+        """
+        H5Lcreate_external(file_name, obj_name, self.id, link_name,
+            pdefault(lcpl), pdefault(lapl))
+
+    @sync
     def get_val(self, char* name, PropID lapl=None):
-        """ (STRING name, PropLAID lapl=None) => STRING or TUPLE(file, obj)
+        """(STRING name, PropLAID lapl=None) => STRING or TUPLE(file, obj)
 
-            Get the string value of a soft link, or a 2-tuple representing
-            the contents of an external link.
+        Get the string value of a soft link, or a 2-tuple representing
+        the contents of an external link.
         """
         cdef hid_t plist = pdefault(lapl)
         cdef H5L_info_t info
@@ -184,17 +194,6 @@ cdef class LinkProxy(ObjectID):
         return py_retval
 
     @sync
-    def create_external(self, char* link_name, char* file_name, char* obj_name,
-        PropID lcpl=None, PropID lapl=None):
-        """ (STRING link_name, STRING file_name, STRING obj_name,
-             PropLCID lcpl=None, PropLAID lapl=None)
-
-            Create a new external link, pointing to an object in another file.
-        """
-        H5Lcreate_external(file_name, obj_name, self.id, link_name,
-            pdefault(lcpl), pdefault(lapl))
-
-    @sync
     def exists(self, char* name):
         """ (STRING name) => BOOL
 
@@ -203,10 +202,12 @@ cdef class LinkProxy(ObjectID):
         return <bint>(H5Lexists(self.id, name, H5P_DEFAULT))
 
     @sync
-    def get_info(self, char* name, PropID lapl=None):
-        """ (STRING name, PropLAID lapl=None) => LinkInfo instance
+    def get_info(self, char* name, int index=-1, *, PropID lapl=None):
+        """(STRING name=, INT index=, **kwds) => LinkInfo instance
+
+        Get information about a link, either by name or its index.
 
-            Get information about a link in this group.
+        Keywords:
         """
         cdef LinkInfo info = LinkInfo()
         H5Lget_info(self.id, name, &info.infostruct, pdefault(lapl))
@@ -215,26 +216,26 @@ cdef class LinkProxy(ObjectID):
     @sync
     def visit(self, object func, *,
               int idx_type=H5_INDEX_NAME, int order=H5_ITER_NATIVE,
-              char* name='.', PropID lapl=None):
-        """ (CALLABLE func, **kwds) => <Return value from func>
+              char* obj_name='.', PropID lapl=None):
+        """(CALLABLE func, **kwds) => <Return value from func>
 
-            Iterate a function or callable object over all groups below this
-            one.  Your callable should conform to the signature:
+        Iterate a function or callable object over all groups below this
+        one.  Your callable should conform to the signature:
 
-                func(STRING name, LinkInfo info) => Result
+            func(STRING name, LinkInfo info) => Result
 
-            Returning None or a logical False continues iteration; returning
-            anything else aborts iteration and returns that value.
+        Returning None or a logical False continues iteration; returning
+        anything else aborts iteration and returns that value.
 
-            Keyword-only arguments:
-            * STRING name ("."):             Visit a subgroup instead
-            * PropLAID lapl (None):          Controls how "name" is interpreted
-            * INT idx_type (h5.INDEX_NAME):  What indexing strategy to use
-            * INT order (h5.ITER_NATIVE):    Order in which iteration occurs
+        Keyword-only arguments:
+        * STRING obj_name ("."):         Visit a subgroup instead
+        * PropLAID lapl (None):          Controls how "obj_name" is interpreted
+        * INT idx_type (h5.INDEX_NAME):  What indexing strategy to use
+        * INT order (h5.ITER_NATIVE):    Order in which iteration occurs
         """
         cdef _LinkVisitor it = _LinkVisitor(func)
 
-        H5Lvisit_by_name(self.id, name, <H5_index_t>idx_type,
+        H5Lvisit_by_name(self.id, obj_name, <H5_index_t>idx_type,
             <H5_iter_order_t>order, cb_link_iterate, <void*>it, pdefault(lapl))
 
         return it.retval
diff --git a/h5py/h5t.pyx b/h5py/h5t.pyx
index b060bde..84db962 100644
--- a/h5py/h5t.pyx
+++ b/h5py/h5t.pyx
@@ -78,6 +78,7 @@ import h5
 cdef H5PYConfig cfg = get_config()
 cdef PHIL phil = get_phil()
 
+
 # === Custom C API ============================================================
 
 cdef TypeID typewrap(hid_t id_):
@@ -1331,4 +1332,3 @@ cpdef TypeID py_create(object dtype_in, dict enum_vals=None):
         phil.release()
 
 
-
diff --git a/h5py/tests/test_h5d.py b/h5py/tests/test_h5d.py
index 5a5b7ab..78d5d44 100644
--- a/h5py/tests/test_h5d.py
+++ b/h5py/tests/test_h5d.py
@@ -83,7 +83,6 @@ class TestH5D(HDF5TestCase):
         space = h5s.create_simple((10,20))
         htype = h5t.STD_I32LE
         dset = h5d.create(root, 'NewDataset', htype, space)
-        del dset
         dset = h5d.open(root, 'NewDataset')
         self.assertEqual(dset.dtype, htype.dtype)
         self.assertEqual(dset.shape, space.shape)
diff --git a/setup.py b/setup.py
index 9bd3127..d3c1f8c 100644
--- a/setup.py
+++ b/setup.py
@@ -398,20 +398,18 @@ class doc(Command):
                 shutil.rmtree('docs/manual-html')
             shutil.copytree('docs/build/html', 'docs/manual-html')
 
-class cyclean(clean):
+class cyclean(Command):
 
-    """ Distutils clean extended to clean up Cython-generated files """
+    """ Clean up Cython-generated files and build cache"""
 
-    user_options = clean.user_options + \
-                   [('doc','d','Also destroy compiled documentation')]
-    boolean_options = clean.boolean_options + ['doc']
+    user_options = [('doc','d','Also destroy compiled documentation')]
+    boolean_options = ['doc']
 
     def initialize_options(self):
         self.doc = False
-        clean.initialize_options(self)
 
     def finalize_options(self):
-        clean.finalize_options(self)
+        pass
 
     def run(self):
         
@@ -419,12 +417,16 @@ class cyclean(clean):
         for x in MODULES.values():
             allmodules.update(x)
 
+        dirs = ['build']
+
         if self.doc:
-            for x in ('docs/api-html', 'docs/manual-html') :
-                try:
-                    shutil.rmtree(x)
-                except OSError:
-                    pass
+            dirs += ['docs/api-html', 'docs/manual-html']
+
+        for x in dirs:
+            try:
+                shutil.rmtree(x)
+            except OSError:
+                pass
 
         fnames = [ op.join(SRC_PATH, x+'.dep') for x in allmodules ] + \
                  [ op.join(SRC_PATH, x+'.c') for x in allmodules ] + \
@@ -436,7 +438,6 @@ class cyclean(clean):
             except OSError:
                 pass
 
-        clean.run(self)
 
 class new_sdist(sdist):
 

-- 
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