[python-hdf5storage] 46/84: Fixed bug where structured ndarrays with UTF-8 encoded fields couldn't be written 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 be360aec5a2ddd7b3323c5772433344d84535c7f
Author: Freja Nordsiek <fnordsie at gmail.com>
Date:   Sun Apr 26 03:53:10 2015 -0400

    Fixed bug where structured ndarrays with UTF-8 encoded fields couldn't be written in Python 2.x
---
 hdf5storage/Marshallers.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/hdf5storage/Marshallers.py b/hdf5storage/Marshallers.py
index daaa51f..ca081ad 100644
--- a/hdf5storage/Marshallers.py
+++ b/hdf5storage/Marshallers.py
@@ -835,8 +835,13 @@ class NumpyScalarArrayMarshaller(TypeMarshaller):
                 or not all(data.shape) \
                 or not all([all(data[n].shape) \
                 for n in data.dtype.names])):
-            # Grab the list of fields.
-            field_names = list(data.dtype.names)
+            # Grab the list of fields. They need to be converted to
+            # unicode in Python 2.x.
+            if sys.hexversion >= 0x03000000:
+                field_names = list(data.dtype.names)
+            else:
+                field_names = [c.decode('UTF-8')
+                               for c in list(data.dtype.names)]
 
             # Write or delete 'Python.Fields' as appropriate.
             if options.store_python_metadata \

-- 
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