Skip to content

Commit d39665f

Browse files
committed
normalize BytesToken values to binary type
fixes UnicodeDecodeError when one value has non-ascii values PYTHON-559
1 parent 869e1ab commit d39665f

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

cassandra/metadata.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,10 +1519,8 @@ class BytesToken(Token):
15191519

15201520
def __init__(self, token_string):
15211521
""" `token_string` should be string representing the token. """
1522-
if not isinstance(token_string, six.string_types):
1523-
raise TypeError(
1524-
"Tokens for ByteOrderedPartitioner should be strings (got %s)"
1525-
% (type(token_string),))
1522+
if isinstance(token_string, six.text_type):
1523+
token_string = token_string.encode('utf-8')
15261524
self.value = token_string
15271525

15281526

0 commit comments

Comments
 (0)