Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

difference in behavior when writing unicode string to attrs (setter vs .create API) #1057

Closed
PiRK opened this issue Jun 21, 2018 · 1 comment · Fixed by #1265
Closed

difference in behavior when writing unicode string to attrs (setter vs .create API) #1057

PiRK opened this issue Jun 21, 2018 · 1 comment · Fixed by #1265

Comments

@PiRK
Copy link

PiRK commented Jun 21, 2018

Hi.
I'm aware that there are many issues already open about writing lists of unicode strings to h5py attributes. But I found that the same problem exists when I try to write a single unicode string using the .create API, while it works fine when I write the string using the setter API.

This works:
h5f["toto"].attrs["toto"] = u"toto"

This causes an error:
h5f["toto"].attrs.create("toto", data=u"toto")
TypeError: No conversion path for dtype: dtype('<U4')

Is there a reason for this difference in behavior? Or would it be possible to also add the if dtype is None: dtype = base.guess_dtype(value) line to the create method, like it is done in __setitem__ ? (https://github.com/h5py/h5py/blob/master/h5py/_hl/attrs.py#L102)

Summary of the h5py configuration

h5py 2.8.0
HDF5 1.10.2
Python 2.7.9 (default, Jun 29 2016, 13:08:31)
[GCC 4.9.2]
sys.platform linux2
sys.maxsize 9223372036854775807
numpy 1.14.5

@aragilar
Copy link
Member

This does seem odd. We should look where guess_dtype is used currently, and try to reduce duplication of conversion code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants