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:
Jian Dai 2018-11-30 00:30:52 +08:00 committed by Asif Saif Uddin
parent a59b44e9fb
commit 571b0ad205
1 changed files with 1 additions and 1 deletions

View File

@ -53,7 +53,7 @@ if PY3: # pragma: no cover
def bytes_to_str(s):
"""Convert bytes to str."""
if isinstance(s, bytes):
return s.decode()
return s.decode(errors='replace')
return s
def from_utf8(s, *args, **kwargs):