Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accept binary key for python2 #427

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

hamano
Copy link

@hamano hamano commented Jan 26, 2016

We can't store binary key such as 0x80(0x79 is OK).
Is there any reason to restrict binary key?

test code

import riak
import binascii
client = riak.RiakClient(host="localhost")
bucket = client.bucket('test')
bucket.new(binascii.unhexlify('79'), data={'value':'79'}).store()
bucket.new(binascii.unhexlify('80'), data={'value':'80'}).store() # error
for key in bucket.get_keys():
    print binascii.hexlify(key), bucket.get(key).data

@lukebakken
Copy link
Contributor

@javajolt - I assume there is a historical reason for this. Perhaps something to do with HTTP vs PB ?

@hazen
Copy link

hazen commented Jan 26, 2016

@lukebakken There was a restriction historically for forcing the keys to be ASCII, before my time. It seems that Python2 is quite limited in its understanding of strings.

>>> binascii.unhexlify('79')
'y'
>>> binascii.unhexlify('80')
'\x80'

Once you start to get into the Unicode realm it escapes things. Python 3 just has binaries. My guess is that some of the HTTP string representations might not work with the \x notation. We could try the integration tests with non-ASCII keys and see what explodes...

@lukebakken
Copy link
Contributor

@hamano - we can't accept this Pull Request without much, much more investigation. At this time yours is the only request to support this feature.

@hamano
Copy link
Author

hamano commented Jan 27, 2016

I've already seen basho/riak#415
HTTP Interface can not representat binary key, but I think It's unrelated to python client using PB.
Actually, other riak client(erlang client) allow to put binary key bucket, but I can't retrive it via python client.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants