Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add nc_del_attr to Cdunif to allow attribute removal in netCDF files #1841
Allow to delete Global Attributes or Variable attributes when calling del(f.attribute) or delattr(f, attribute). Cdunifmodule "set_attribute" function is called with a null pointer "0x00" which is different than Py_None. Without this change deleting an attribute with a "del" or "delattr" call was crashing the program with a segmentation fault.
@dnadeau4 can you please add a test case? Thanks!
import cdms2, MV f = cdms2.open("test.nc","w") s = MV2.ones((20,20)) s.id="test" s.test_attribute = "some variable attribute" f.test_attribute = "some file attribute" f.write(s) f.close() f = cdms2.open("test.nc","r+") del(f.some_attribute) s=f["test"] del(s.some_attribute) f.close() f = cdms2.open("test.nc") assert(hasattr(f,"some_attribute") is False) s=f["test"] assert(hasattr(s,"some_attribute") is False)