GitHub user pzrq opened a pull request:
https://github.com/apache/libcloud/pull/767
PY3: Change libcloud.common.base.Response.body from str to bytes type
## PY3: Change libcloud.common.base.Response.body from str to bytes type
### Description
Let's at least fix the case where if `lxml` is present, AWS S3
`list_containers()` raises an error in normal operation, and roll forward as we
discover other things that actually need fixing.
See #762
### Status
- done, ready for review (I'm sure someone will let me know if it needs
more testing in light of #762)
### Checklist (tick everything that applies)
- [ ] [Code
linting](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide)
(required, can be done after the PR checks)
- [ ] Documentation
- [ ] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html)
- [ ]
[ICLA](http://libcloud.readthedocs.org/en/latest/development.html#contributing-bigger-changes)
(required for bigger changes)
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/mathspace/libcloud py3.5-lxml-body-to-bytes
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/libcloud/pull/767.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #767
----
commit 47462c16d330b8bf33a537e832b43c71bccc8fe6
Author: Peter Schmidt <[email protected]>
Date: 2016-04-18T01:56:26Z
PY3: Change Response.body from str to bytes type and update tests
This makes it more consistent with:
* requests.models.Response.content
https://github.com/kennethreitz/requests/blob/fb23070/requests/models.py#L727-L729
* django.http.response.HttpResponse.content
https://github.com/django/django/blob/1.9.5/django/http/response.py#L303-L305
Long term not sure if there's an appetite to deprecate libcloud's
Response.body entirely.
Fixes my AWS S3 error at least:
from libcloud.storage.types import ObjectDoesNotExistError, Provider
from libcloud.storage.providers import get_driver
driver_cls = get_driver(Provider.S3_US_WEST)
# Get keys from following
#
http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSGettingStartedGuide/AWSCredentials.html
driver = driver_cls('your_access_key','your_secret_key')
driver.list_containers()
Results in MalformedResponseError:
# Note: Added some whitespace for readability and redacted some possibly
sensitive info
MalformedResponseError: <MalformedResponseException in
<libcloud.storage.drivers.s3.S3USWestStorageDriver object at 0x10856e128>
'Failed to parse XML'>:
'<?xml version="1.0" encoding="UTF-8"?>
<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Owner>
<ID>redacted</ID>
<DisplayName>redacted</DisplayName>
</Owner>
<Buckets>
<Bucket><Name>redacted</Name><CreationDate>2011-06-23T16:49:03.000Z</CreationDate></Bucket>
<Bucket><Name>redacted</Name><CreationDate>2016-04-14T06:49:08.000Z</CreationDate></Bucket>
<Bucket><Name>redacted</Name><CreationDate>2011-06-24T06:57:52.000Z</CreationDate></Bucket>
</Buckets>
</ListAllMyBucketsResult>'
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---