mirror of https://github.com/celery/kombu.git
fix bytes_to_str bug (#747)
When we were using celery , and using `pickle` format to transfer a bytes variable like a file content, for example a picture file, then we will get an exception here. ```UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte``` So add `errors='replace'` to avoid the encoding error here.
This commit is contained in:
parent
a59b44e9fb
commit
571b0ad205
|
@ -53,7 +53,7 @@ if PY3: # pragma: no cover
|
||||||
def bytes_to_str(s):
|
def bytes_to_str(s):
|
||||||
"""Convert bytes to str."""
|
"""Convert bytes to str."""
|
||||||
if isinstance(s, bytes):
|
if isinstance(s, bytes):
|
||||||
return s.decode()
|
return s.decode(errors='replace')
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def from_utf8(s, *args, **kwargs):
|
def from_utf8(s, *args, **kwargs):
|
||||||
|
|
Loading…
Reference in New Issue