[python-hdf5storage] 44/84: Fixed bug where structured ndarrays with non-ascii characters in fields couldn't be read in Python 2.x
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Feb 29 08:25:02 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to annotated tag 0.1.10
in repository python-hdf5storage.
commit 18fdf881198d5600e77fa1d8b576dd105d8a358b
Author: Freja Nordsiek <fnordsie at gmail.com>
Date: Sun Apr 26 03:39:36 2015 -0400
Fixed bug where structured ndarrays with non-ascii characters in fields couldn't be read in Python 2.x
---
hdf5storage/Marshallers.py | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/hdf5storage/Marshallers.py b/hdf5storage/Marshallers.py
index d553079..d0a8fab 100644
--- a/hdf5storage/Marshallers.py
+++ b/hdf5storage/Marshallers.py
@@ -1007,8 +1007,8 @@ class NumpyScalarArrayMarshaller(TypeMarshaller):
struct_data[k] = read_data(f, grp[name], k,
options)
else:
- struct_data[k.encode()] = read_data(f, \
- grp[name], k, options)
+ struct_data[k] = \
+ read_data(f, grp[name], k, options)
except:
pass
@@ -1050,7 +1050,7 @@ class NumpyScalarArrayMarshaller(TypeMarshaller):
if sys.hexversion >= 0x03000000:
k_name = k
else:
- k_name = k.encode()
+ k_name = k.encode('UTF-8')
# Read the value.
v = struct_data[k]
@@ -1102,7 +1102,10 @@ class NumpyScalarArrayMarshaller(TypeMarshaller):
# the shape is an empty shape.
if all(data.shape) and all(v.shape):
for index, x in np.ndenumerate(v):
- data[k][index] = x
+ if sys.hexversion >= 0x03000000:
+ data[k][index] = x
+ else:
+ data[k.encode('UTF-8')][index] = x
# If metadata is present, that can be used to do convert to the
# desired/closest Python data types. If none is present, or not
@@ -1123,8 +1126,8 @@ class NumpyScalarArrayMarshaller(TypeMarshaller):
if sys.hexversion >= 0x03000000:
struct_dtype.append((k, 'object'))
else:
- struct_dtype.append((k.encode('ascii'),
- 'object'))
+ struct_dtype.append((k.encode('UTF-8'),
+ 'object'))
else:
struct_dtype = None
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-hdf5storage.git
More information about the debian-science-commits
mailing list