[python-hdf5storage] 14/84: Added check for non-unicode keys in PythonDictMarshaller right to the beginning of the writing process so that nothing is changed if there is a non-unicode key.
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Feb 29 08:24:58 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 cc763ffedff3b02f3202f6954c073a20f696e3eb
Author: Freja Nordsiek <fnordsie at gmail.com>
Date: Thu Aug 14 16:47:34 2014 -0400
Added check for non-unicode keys in PythonDictMarshaller right to the beginning of the writing process so that nothing is changed if there is a non-unicode key.
---
hdf5storage/Marshallers.py | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/hdf5storage/Marshallers.py b/hdf5storage/Marshallers.py
index b3fafa3..4fc5f14 100644
--- a/hdf5storage/Marshallers.py
+++ b/hdf5storage/Marshallers.py
@@ -1385,6 +1385,25 @@ class PythonDictMarshaller(TypeMarshaller):
self.matlab_classes = list()
def write(self, f, grp, name, data, type_string, options):
+ # Check for any field names that are not unicode since they
+ # cannot be handled. How it is checked (what type it is) and the
+ # error message are different for each Python version.
+
+ if sys.hexversion >= 0x03000000:
+ for fieldname in data:
+ if not isinstance(fieldname, str):
+ raise NotImplementedError('Dictionaries with non-'
+ + 'str keys are not '
+ + 'supported: '
+ + repr(fieldname))
+ else:
+ for fieldname in data:
+ if not isinstance(fieldname, unicode):
+ raise NotImplementedError('Dictionaries with non-'
+ + 'unicode keys are not '
+ + 'supported: '
+ + repr(fieldname))
+
# If the group doesn't exist, it needs to be created. If it
# already exists but is not a group, it needs to be deleted
# before being created.
@@ -1408,25 +1427,6 @@ class PythonDictMarshaller(TypeMarshaller):
set([i for i in data])):
del grp2[field]
- # Check for any field names that are not unicode since they
- # cannot be handled. How it is checked (what type it is) and the
- # error message are different for each Python version.
-
- if sys.hexversion >= 0x03000000:
- for fieldname in data:
- if not isinstance(fieldname, str):
- raise NotImplementedError('Dictionaries with non-'
- + 'str keys are not '
- + 'supported: '
- + repr(fieldname))
- else:
- for fieldname in data:
- if not isinstance(fieldname, unicode):
- raise NotImplementedError('Dictionaries with non-'
- + 'unicode keys are not '
- + 'supported: '
- + repr(fieldname))
-
# Go through all the elements of data and write them. The H5PATH
# needs to be set as the path of grp2 on all of them if we are
# doing MATLAB compatibility (otherwise, the attribute needs to
--
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