HDF5File attributes are broken (from python)

Issue #374 resolved
Martin Sandve Alnæs created an issue

Only tested this from python. Reproduce:

from dolfin import *
hdf_file = HDF5File(mpi_comm_world(), "myfile.h5", "w")
x = Vector(mpi_comm_world(), 123)
vecname = "/a_vector"
hdf_file.write(x, vecname)
attr = hdf_file.attributes(vecname)
assert attr.exists("name") == False
attr["name"] = "John"
assert attr.exists("name") == True
assert attr.get("name") == "John" # Crash

# output:
"""
*** Error:   Unable to complete call to function get_attribute_value().
*** Reason:  Assertion H5Tget_class(attr_type) == H5Tget_class(h5type) failed.
*** Where:   This error was encountered inside ../../dolfin/io/HDF5Interface.h (line 596).
"""

Comments (5)

  1. Chris Richardson

    I'm not sure what has happened with this, because I did get it crashing (as above), but when I rebuilt with the latest master, the get() method is not exposed in python, and you can correctly get the attribute value back by using the __getitem__() method, i.e.

    print attr["name"]
    

    works. Can you try that?

  2. Log in to comment