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

Incompatibility with "requests" 2.9.0, just released #89

Closed
jcea opened this issue Dec 16, 2015 · 3 comments
Closed

Incompatibility with "requests" 2.9.0, just released #89

jcea opened this issue Dec 16, 2015 · 3 comments

Comments

@jcea
Copy link

jcea commented Dec 16, 2015

My code worked perfectly so far, but when requests ungraded to 2.9.0, I get this exception:

  File "/usr/local/lib/python3.5/site-packages/azure/storage/blob/blobservice.py", line 1228, in put_block_blob_from_bytes
    x_ms_lease_id)
  File "/usr/local/lib/python3.5/site-packages/azure/storage/blob/blobservice.py", line 883, in put_blob
    self._perform_request(request)
  File "/usr/local/lib/python3.5/site-packages/azure/storage/storageclient.py", line 171, in _perform_request
    resp = self._filter(request)
  File "/usr/local/lib/python3.5/site-packages/azure/storage/storageclient.py", line 160, in _perform_request_worker
    return self._httpclient.perform_request(request)
  File "/usr/local/lib/python3.5/site-packages/azure/storage/_http/httpclient.py", line 181, in perform_request
    self.send_request_body(connection, request.body)
  File "/usr/local/lib/python3.5/site-packages/azure/storage/_http/httpclient.py", line 143, in send_request_body
    connection.send(request_body)
  File "/usr/local/lib/python3.5/site-packages/azure/storage/_http/requestsclient.py", line 81, in send
    self.response = self.session.request(self.method, self.uri, data=request_body, headers=self.headers, timeout=self.timeout)
  File "/usr/local/lib/python3.5/site-packages/requests/sessions.py", line 454, in request
    prep = self.prepare_request(req)
  File "/usr/local/lib/python3.5/site-packages/requests/sessions.py", line 388, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/local/lib/python3.5/site-packages/requests/models.py", line 296, in prepare
    self.prepare_body(data, files, json)
  File "/usr/local/lib/python3.5/site-packages/requests/models.py", line 447, in prepare_body
    body = self._encode_params(data)
  File "/usr/local/lib/python3.5/site-packages/requests/models.py", line 84, in _encode_params
    return to_native_string(data)
  File "/usr/local/lib/python3.5/site-packages/requests/utils.py", line 700, in to_native_string
    out = string.decode(encoding)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)
@jcea
Copy link
Author

jcea commented Dec 16, 2015

Minimal testcase:

data = b'\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04\xe9\x80\t\x98\xec\xf8B~'
blob_service.put_block_blob_from_bytes(
        container_name = 'test',
        blob_name = "test",
        blob = data,
        )

Maybe related to this change in Request 2.9.0:

We now handle being passed a query string as a bytestring on Python 3, by decoding it as UTF-8.

@lmazuel
Copy link
Member

lmazuel commented Dec 16, 2015

Thank you for your report.

After investigation it seems that it's a problem in requests, I opened a bug in the requests repo for that.
https://github.com/kennethreitz/requests/issues/2933

@jcea
Copy link
Author

jcea commented Dec 17, 2015

Waiting for a new requests release. I close this bug.

Thanks for your time and fast reply.

@jcea jcea closed this as completed Dec 17, 2015
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

No branches or pull requests

2 participants