Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nc_del_attr to Cdunif to allow attribute removal in netCDF files #1841

Merged
merged 4 commits into from
Feb 19, 2016

Conversation

dnadeau4
Copy link
Contributor

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 dnadeau4 changed the title Add nc_del_attr to Cdunif to allow attribute remove in netCDF files Add nc_del_attr to Cdunif to allow attribute removal in netCDF files Feb 18, 2016
@doutriaux1
Copy link
Contributor

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

@dnadeau4
Copy link
Contributor Author

I added the test.

@durack1
Copy link
Member

durack1 commented Feb 19, 2016

@dnadeau4 it would be a good idea to merge these changes into the existing branch issue1579_durack1_UpdateNetcdf4.3.3.1To4.4.0 - this branch includes the new netcdf 4.4.0 final release..

@doutriaux1
Copy link
Contributor

@durack1 totally different issue, one issue per branch. The NetCDF4 needs testing first.

@durack1
Copy link
Member

durack1 commented Feb 19, 2016

@doutriaux1 not sure I agree with you. In 4.4.0 Unidata/netcdf-c#128 is fixed, and these changes will likely impact the operation of Cdunif. This is documented in #1398

@dnadeau4
Copy link
Contributor Author

@doutriaux1 How come you did not merge it yet? I did add the test and I tried it. Thanks for providing a template.

@doutriaux1
Copy link
Contributor

my bad, didn't see that you had a test in!

gave a more unique name to test file
doutriaux1 added a commit that referenced this pull request Feb 19, 2016
Add nc_del_attr to Cdunif to allow attribute removal in netCDF files
@doutriaux1 doutriaux1 merged commit 8bb4dda into master Feb 19, 2016
@doutriaux1 doutriaux1 deleted the nc_del_attr branch February 19, 2016 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants