ome / omero-py

Python project containing Ice remoting code for OMERO
https://www.openmicroscopy.org/omero
GNU General Public License v2.0
22 stars 32 forks source link

Fix tables StringColumn unicode #143

Closed manics closed 4 years ago

manics commented 4 years ago

Replacement for https://github.com/ome/omero-py/pull/133

See comment in hdfstorageV2.HdfStorage.append (https://github.com/ome/omero-py/commit/9e1d8e00873f76a2a2972a0c96de1494639c9c48) for the full explanation

Probably needs a doc update to say string column sizes must be given as the number of bytes not the number of unicode characters.

manics commented 4 years ago

The last commit fails on Python 2.7 with the inexplicable error:

    def arrays(self):
        """
        Check for strings longer than the initialised column width
        """
        for v in self.values:
>           if sys.version_info >= (3, 0, 0):
E           AttributeError: 'module' object has no attribute 'version_info'

https://travis-ci.org/ome/omero-py/jobs/620734836 Python 3 is fine, and the code works fine in the rest of omero-py ¯\_(ツ)_/¯

joshmoore commented 4 years ago

There is also an omero.sys module which is likely what Py2 is picking up. There are existing import gymnastics to handle that.

joshmoore commented 4 years ago

(Title is probably also a bit off now, eh? 🙂)

manics commented 4 years ago

It might be possible to simplify this by moving the conversion into StringColumnI.arrays() so bytes are always returned. This assumes arrays() isn't used anywhere else.

manics commented 4 years ago

See last commit on https://github.com/ome/omero-py/pull/145/ re the last comment