Closed
Description
File "/root/.local/share/virtualenvs/celery-jR7fJ1bi/lib/python3.5/site-packages/elasticsearch/client/utils.py", line 32, in _escape
return value.encode('utf-8')
AttributeError: 'bytes' object has no attribute 'encode'
It appears that when _escape receives value, which in my case is b'celery-task-meta-c4f1201f-eb7b-41d5-9318-a75a8cfbdaa0', it gets checked against (<class 'str'>, <class 'bytes'>), and therefore passes the test but <class 'bytes'> does not have the encode method.
try does not catch as error is AttributeError: 'bytes' object has no attribute 'encode'
def _escape(value):
"""
Escape a single value of a URL string or a query parameter. If it is a list
or tuple, turn it into a comma-separated string first.
"""
# make sequences into comma-separated stings
if isinstance(value, (list, tuple)):
value = ','.join(value)
# dates and datetimes into isoformat
elif isinstance(value, (date, datetime)):
value = value.isoformat()
# make bools into true/false strings
elif isinstance(value, bool):
value = str(value).lower()
# encode strings to utf-8
if isinstance(value, string_types):
try:
return value.encode('utf-8')
except UnicodeDecodeError:
# Python 2 and str, no need to re-encode
pass
return str(value)
Metadata
Metadata
Assignees
Labels
No labels