Skip to content

Commit 4f0df75

Browse files
committed
ensure bytes for blosc name
1 parent 4682c7d commit 4f0df75

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

zarr/compressors.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import absolute_import, print_function, division
3-
import zlib
4-
import bz2
53

4+
import bz2
5+
import zlib
66

77
import numpy as np
88

9-
10-
from zarr.compat import text_type
9+
from .compat import text_type
10+
from .util import ensure_bytes
1111

1212

1313
registry = dict()
@@ -122,7 +122,7 @@ def normalize_opts(cls, compression_opts):
122122
cname = cname if cname is not None else cls.default_cname
123123

124124
# check internal compressor is available
125-
if blosc.compname_to_compcode(cname) < 0:
125+
if blosc.compname_to_compcode(ensure_bytes(cname)) < 0:
126126
raise ValueError('blosc internal compressor not available: %s'
127127
% cname)
128128

zarr/util.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,10 @@ def normalize_order(order):
187187
if order not in ['C', 'F']:
188188
raise ValueError("order must be either 'C' or 'F', found: %r" % order)
189189
return order
190+
191+
192+
def ensure_bytes(s):
193+
if hasattr(s, 'encode'):
194+
return s.encode()
195+
else:
196+
return s

0 commit comments

Comments
 (0)