HDFGroup / h5serv

Reference service implementation of the HDF5 REST API
Other
168 stars 35 forks source link

Assigning Unicode string objects to string datasets #48

Closed ghost closed 9 years ago

ghost commented 9 years ago

These changes fix this issue: HDFGroup/hpd-ws#26.

I traced the problem to assignment of a Unicode string object, e.g. u"Hello world!" to an already created dataset of the ASCII datatype (per its JSON information). When the json package converts JSON to Python dictionary all strings, its keys and string values, are Unicode string objects.

The crux of the changes are:

  1. Allow conversion of every string value from JSON into the Python's str object.
  2. Do not accept H5T_STRING object values from JSON as-is.

I would keep this branch alive for testing when assigning str or unicode objects to UTF-8 string datasets.

jreadey commented 9 years ago

It's hard to sort out the relevant change among all the white space updates. Is just around line 1066 that has the relevant update?

ghost commented 9 years ago

I apologize for the "white noise" of changes. Can you configure your text editor to remove all the excess white space?

I put "Here!" to mark relevant code changes.

ghost commented 9 years ago

I just checked h5py's tests and fixed-length Unicode datasets are not supported. Vlen Unicode datasets are.

jreadey commented 9 years ago

test script passes ok, went ahead and merged to master.