bytearray not handled correctly as content (but bytes is)

Bug #1741991 reported by Ben Blamey
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-swiftclient
New
Undecided
Unassigned

Bug Description

Attempting PUT_OBJECT with content of type 'bytes' is handled correctly.

With the check in client.py:1317, the iter_wrapper is not used for bytes.

However, the check does not include bytearray - hence the iter_wrapper is used, and fails, because the iterated items in bytearray are themselves integers, not arrays of bytes.

'bytearray' should be handled the same way as 'bytes'.

Stack trace looks like this:
  File "/usr/local/lib/python3.6/site-packages/swiftclient/client.py", line 1829, in put_object
    response_dict=response_dict)
  File "/usr/local/lib/python3.6/site-packages/swiftclient/client.py", line 1678, in _retry
    service_token=self.service_token, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/swiftclient/client.py", line 1317, in put_object
    conn.request('PUT', path, contents, headers)
  File "/usr/local/lib/python3.6/site-packages/swiftclient/client.py", line 439, in request
    files=files, **self.requests_args)
  File "/usr/local/lib/python3.6/site-packages/swiftclient/client.py", line 422, in _request
    return self.request_session.request(*arg, **kwarg)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 460, in send
    for i in request.body:
  File "/usr/local/lib/python3.6/site-packages/swiftclient/utils.py", line 364, in iter_wrapper
    if len(chunk) == 0:

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.