diff options
Diffstat (limited to 'silx/gui/data/TextFormatter.py')
-rw-r--r-- | silx/gui/data/TextFormatter.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/silx/gui/data/TextFormatter.py b/silx/gui/data/TextFormatter.py index 98c37d7..8fd7c7c 100644 --- a/silx/gui/data/TextFormatter.py +++ b/silx/gui/data/TextFormatter.py @@ -267,6 +267,12 @@ class TextFormatter(qt.QObject): if vlen is not None: if vlen == six.text_type: # HDF5 UTF8 + # With h5py>=3 reading dataset returns bytes + if isinstance(data, (bytes, numpy.bytes_)): + try: + data = data.decode("utf-8") + except UnicodeDecodeError: + self.__formatSafeAscii(data) return self.__formatText(data) elif vlen == six.binary_type: # HDF5 ASCII @@ -289,7 +295,7 @@ class TextFormatter(qt.QObject): elif isinstance(data, list): text = [self.toString(d) for d in data] return "[" + " ".join(text) + "]" - elif isinstance(data, (numpy.ndarray)): + elif isinstance(data, numpy.ndarray): if dtype is None: dtype = data.dtype if data.shape == (): |