Skip to content

Commit 3325d67

Browse files
committed
raise error when trying to set _FillValue using setncattr.
1 parent 0bc37d8 commit 3325d67

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

netCDF4/_netCDF4.pyx

+7
Original file line numberDiff line numberDiff line change
@@ -4112,6 +4112,13 @@ netCDF attribute with the same name as one of the reserved python
41124112
attributes."""
41134113
cdef nc_type xtype
41144114
xtype=-99
4115+
# issue #959 - trying to set _FillValue results in mysterious
4116+
# error when close method is called so catch it here. It is
4117+
# already caught in __setattr__.
4118+
if name == '_FillValue':
4119+
msg='_FillValue attribute must be set when variable is '+\
4120+
'created (using fill_value keyword to createVariable)'
4121+
raise AttributeError(msg)
41154122
if self._grp.data_model != 'NETCDF4': self._grp._redef()
41164123
_set_att(self._grp, self._varid, name, value, xtype=xtype, force_ncstring=self._ncstring_attrs__)
41174124
if self._grp.data_model != 'NETCDF4': self._grp._enddef()

0 commit comments

Comments
 (0)