Skip to content

Commit 0bbc9d1

Browse files
jswhit2jswhit2
authored andcommitted
tentative fixes for issue #1440
1 parent 2ae97c3 commit 0bbc9d1

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

Changelog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
version 1.7.4 (not yet released)
2+
================================
13
version 1.7.3 (tag v1.7.3rel)
24
=============================
35
* Python 3.14 wheels (issue #1432)

include/netcdf-compat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static inline int nc_get_alignment(int* thresholdp, int* alignmentp) {
6060
#else
6161
#define HAS_NCRCSET 0
6262
static inline int nc_rc_set(const char* key, const char* value) { return NC_EINVAL; }
63-
static inline const char *nc_rc_get(const char* key) { return NC_EINVAL; }
63+
static inline const char *nc_rc_get(const char* key) { return NULL; }
6464
#endif
6565

6666
#if NC_VERSION_GE(4, 4, 0)

src/netCDF4/_netCDF4.pyx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5525,7 +5525,11 @@ cannot be safely cast to variable data type""" % attname
55255525
# if data is a string or a bytes object, convert to a numpy string array
55265526
# whose length is equal to the rightmost dimension of the
55275527
# variable.
5528-
if type(data) in [str,bytes]: data = numpy.asarray(data,dtype='S'+repr(self.shape[-1]))
5528+
if type(data) in [str,bytes]:
5529+
if encoding == 'ascii':
5530+
data = numpy.asarray(data,dtype='S'+repr(self.shape[-1]))
5531+
else:
5532+
data = numpy.asarray(data,dtype='U'+repr(self.shape[-1]))
55295533
if data.dtype.kind in ['S','U'] and data.dtype.itemsize > 1:
55305534
# if data is a numpy string array, convert it to an array
55315535
# of characters with one more dimension.
@@ -6816,15 +6820,12 @@ returns a numpy string array with datatype `'UN'` (or `'SN'`) and shape
68166820
dtype = b.dtype.kind
68176821
if dtype not in ["S","U"]:
68186822
raise ValueError("type must be string or unicode ('S' or 'U')")
6819-
if encoding in ['none','None','bytes']:
6820-
bs = b.tobytes()
6821-
else:
6822-
bs = b.tobytes().decode(encoding)
6823+
bs = b.tobytes()
68236824
slen = int(b.shape[-1])
68246825
if encoding in ['none','None','bytes']:
68256826
a = numpy.array([bs[n1:n1+slen] for n1 in range(0,len(bs),slen)],'S'+repr(slen))
68266827
else:
6827-
a = numpy.array([bs[n1:n1+slen] for n1 in range(0,len(bs),slen)],'U'+repr(slen))
6828+
a = numpy.array([bs[n1:n1+slen].decode(encoding) for n1 in range(0,len(bs),slen)],'U'+repr(slen))
68286829
a.shape = b.shape[:-1]
68296830
return a
68306831

0 commit comments

Comments
 (0)