diff options
author | Mike Schwartz <mfschwartz@google.com> | 2019-03-21 13:43:00 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-21 13:43:00 -0600 |
commit | acd6a95ad953a4f1ac72adfc354a6c5aec74fbb0 (patch) | |
tree | 4dc014ad2f71d37aaddcb9caa78ecde9cc7e60e0 | |
parent | 4627673637645e538ac720f987026f3c533bf99f (diff) | |
parent | d4761521a296dd85e0cf06925afcfabd1c3d03aa (diff) | |
download | boto-acd6a95ad953a4f1ac72adfc354a6c5aec74fbb0.tar.gz |
Merge pull request #3858 from gsutil-mirrors/fix-failing-tests-after-py3-commits
Fix test failures introduced in #3855 and #3866.
-rw-r--r-- | boto/s3/key.py | 10 | ||||
-rw-r--r-- | tests/integration/s3/mock_storage_service.py | 21 |
2 files changed, 7 insertions, 24 deletions
diff --git a/boto/s3/key.py b/boto/s3/key.py index b0bc40f0..35f04c9f 100644 --- a/boto/s3/key.py +++ b/boto/s3/key.py @@ -392,7 +392,7 @@ class Key(object): By providing a next method, the key object supports use as an iterator. For example, you can now say: - for bytes in key: + for key_bytes in key: write bytes to a file or whatever All of the HTTP connection stuff is handled for you. @@ -1552,11 +1552,11 @@ class Key(object): i = 0 cb(data_len, cb_size) try: - for bytes in self: - six.ensure_binary(bytes, file=fp, end='') - data_len += len(bytes) + for key_bytes in self: + print(key_bytes, file=fp, end='') + data_len += len(key_bytes) for alg in digesters: - digesters[alg].update(bytes) + digesters[alg].update(key_bytes) if cb: if cb_size > 0 and data_len >= cb_size: break diff --git a/tests/integration/s3/mock_storage_service.py b/tests/integration/s3/mock_storage_service.py index e9a55563..aece4902 100644 --- a/tests/integration/s3/mock_storage_service.py +++ b/tests/integration/s3/mock_storage_service.py @@ -30,7 +30,6 @@ import copy import boto import base64 import re -import locale from hashlib import md5 from boto.utils import compute_md5 @@ -89,23 +88,7 @@ class MockKey(object): torrent=NOT_IMPL, version_id=NOT_IMPL, res_download_handler=NOT_IMPL): - if isinstance(self.data, six.binary_type): - if 'b' in fp.mode: - # data is bytes, and fp is binary - fp.write(self.data) - elif hasattr(fp, 'buffer'): - # data is bytes, but fp is text - try the underlying buffer - fp.buffer.write(self.data) - else: - # data is bytes, but fp is text - try to decode bytes - fp.write( - self.data.decode(locale.getpreferredencoding(False))) - elif 'b' in fp.mode: - # data is not bytes, but fp is binary - fp.write(self.data.encode(locale.getpreferredencoding(False))) - else: - # data is not bytes, and fp is text - fp.write(self.data) + fp.write(self.data) def get_file(self, fp, headers=NOT_IMPL, cb=NOT_IMPL, num_cb=NOT_IMPL, torrent=NOT_IMPL, version_id=NOT_IMPL, @@ -164,7 +147,7 @@ class MockKey(object): cb=NOT_IMPL, num_cb=NOT_IMPL, policy=NOT_IMPL, reduced_redundancy=NOT_IMPL, query_args=NOT_IMPL, size=NOT_IMPL): - self.data = b'' + self.data = '' chunk = fp.read(self.BufferSize) while chunk: self.data += chunk |