Boto: Boto S3 throws type error in production environment

Created on 22 Jun 2016  路  5Comments  路  Source: boto/boto

It is working fine on my local, but when I try to use it in celery, in production environment, it throws a type error. Can someone guide me, what could have caused the error?

 bucket = conn.get_bucket(settings.AWS_STORAGE_BUCKET_NAME)
  File "/usr/local/lib/python3.5/dist-packages/boto/s3/connection.py", line 506, in get_bucket
    return self.head_bucket(bucket_name, headers=headers)
  File "/usr/local/lib/python3.5/dist-packages/boto/s3/connection.py", line 525, in head_bucket
    response = self.make_request('HEAD', bucket_name, headers=headers)
  File "/usr/local/lib/python3.5/dist-packages/boto/s3/connection.py", line 668, in make_request
    retry_handler=retry_handler
  File "/usr/local/lib/python3.5/dist-packages/boto/connection.py", line 1071, in make_request
    retry_handler=retry_handler)
  File "/usr/local/lib/python3.5/dist-packages/boto/connection.py", line 913, in _mexe
    self.is_secure)
  File "/usr/local/lib/python3.5/dist-packages/boto/connection.py", line 705, in get_http_connection
    return self.new_http_connection(host, port, is_secure)
  File "/usr/local/lib/python3.5/dist-packages/boto/connection.py", line 747, in new_http_connection
    connection = self.proxy_ssl(host, is_secure and 443 or 80)
  File "/usr/local/lib/python3.5/dist-packages/boto/connection.py", line 796, in proxy_ssl
    sock.sendall("CONNECT %s HTTP/1.0\r\n" % host)
TypeError: a bytes-like object is required, not 'str'

All 5 comments

This is a Python 3 compatibility issue. It should work fine if you use Python 2.

Edit 2018: When I made this comment, S3 didn't claim Py3 support

For anyone else who encounters this problem and ends up here - there is a merge request with a fix: https://github.com/boto/boto/pull/2718.

Also note: this issue is only triggered when using proxies.

...and is there a solution when using proxies?

Yeah, this need to be merged: https://github.com/boto/boto/pull/3699

Was this page helpful?
0 / 5 - 0 ratings