Aug-12-2020, 10:52 PM
I am trying to use the boto library with python3 to upload the data to GCS buckets. My data is latin-1 encoded, but it fails with following exception
>>> get_utf8_value(zlib.compress(b'test').decode('latin-1'))b'x\xc2\x9c+I-.\x01\x00\x04]\x01\xc3\x81'>>> from boto.compat import StringIO>>> StringIO(get_utf8_value(zlib.compress(b'test').decode('latin-1')))Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: initial_value must be str or None, not bytes
>>> from boto.utils import get_utf8_value
>>> get_utf8_value(zlib.compress(b'test').decode('latin-1'))
>>> from boto.compat import StringIO
>>> StringIO(get_utf8_value(zlib.compress(b'test').decode('latin-1')))
Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: initial_value must be str or None, not bytes
>>> get_utf8_value(zlib.compress(b'test').decode('latin-1'))b'x\xc2\x9c+I-.\x01\x00\x04]\x01\xc3\x81'>>> from boto.compat import StringIO>>> StringIO(get_utf8_value(zlib.compress(b'test').decode('latin-1')))Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: initial_value must be str or None, not bytes
>>> from boto.utils import get_utf8_value
>>> get_utf8_value(zlib.compress(b'test').decode('latin-1'))
>>> from boto.compat import StringIO
>>> StringIO(get_utf8_value(zlib.compress(b'test').decode('latin-1')))
Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: initial_value must be str or None, not bytes