Skip to content

Commit 1b0876d

Browse files
Merge pull request #1 from pp-mo/vlen_safe_nc
Use 'safe-access' version of netCDF4.VLType
2 parents fc871ba + 4c16226 commit 1b0876d

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

lib/iris/fileformats/netcdf/_thread_safe_nc.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# Doesn't need thread protection, but this allows all netCDF4 refs to be
2121
# replaced with thread_safe refs.
2222
default_fillvals = netCDF4.default_fillvals
23+
VLType = netCDF4.VLType
2324

2425

2526
class _ThreadSafeWrapper(ABC):

lib/iris/fileformats/netcdf/loader.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def _get_cf_var_data(cf_var, filename):
225225
# data; see https://github.com/Unidata/netcdf-c/issues/1893.
226226
# Note: "Variable length" netCDF types have a datatype of `nc.VLType`.
227227
if isinstance(
228-
getattr(cf_var, "datatype", None), _thread_safe_nc.netCDF4.VLType
228+
getattr(cf_var, "datatype", None), _thread_safe_nc.VLType
229229
):
230230
msg = (
231231
f"NetCDF variable `{cf_var.cf_name}` is a variable length type of kind {cf_var.dtype} "

lib/iris/tests/unit/fileformats/netcdf/loader/test__get_cf_var_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
from unittest import mock
1212

1313
import dask.array as da
14-
from netCDF4 import VLType
1514
import numpy as np
1615

1716
from iris._lazy_data import _optimum_chunksize
1817
import iris.fileformats.cf
18+
from iris.fileformats.netcdf._thread_safe_nc import VLType
1919
from iris.fileformats.netcdf.loader import CHUNK_CONTROL, _get_cf_var_data
2020

2121

0 commit comments

Comments
 (0)