Skip to content

Commit 4653710

Browse files
committed
Disable byte decoding on load.
1 parent 9c06cca commit 4653710

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/iris/fileformats/cf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ def __init__(self, name, data):
8989

9090
self.cf_data = data
9191
"""NetCDF4 Variable data instance."""
92+
# Note: *always* disable encoding/decoding translations
93+
# To avoid current known problems
94+
# See https://github.com/Unidata/netcdf4-python/issues/1440
95+
data.set_auto_chartostring(False)
96+
# ALSO NOTE: not stored. NetCDFDataProxy must re-assert when re-loading.
9297

9398
"""File source of the NetCDF content."""
9499
try:

lib/iris/fileformats/netcdf/_thread_safe_nc.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,11 @@ def __getitem__(self, keys):
336336
dataset = netCDF4.Dataset(self.path)
337337
try:
338338
variable = dataset.variables[self.variable_name]
339+
# ALWAYS disable byte encoding/decoding
340+
# To avoid current known problems
341+
# See https://github.com/Unidata/netcdf4-python/issues/1440
342+
variable.set_auto_chartostring(False)
343+
339344
# Get the NetCDF variable data and slice.
340345
var = variable[keys]
341346
finally:

0 commit comments

Comments
 (0)