diff options
author | Jian Dai <daijian1@qq.com> | 2018-11-30 00:30:52 +0800 |
---|---|---|
committer | Asif Saif Uddin <auvipy@gmail.com> | 2018-11-29 22:30:52 +0600 |
commit | 571b0ad205ab8d71df7ec489a1fab7b17e1668da (patch) | |
tree | e8cc5d9ee95e3cf7efad6cf3d94948d22fe0cbf4 | |
parent | a59b44e9fb8d00758dd6a3c560e2f158e672580d (diff) | |
download | kombu-571b0ad205ab8d71df7ec489a1fab7b17e1668da.tar.gz |
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.
-rw-r--r-- | kombu/utils/encoding.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kombu/utils/encoding.py b/kombu/utils/encoding.py index 93788bde..551cf5f3 100644 --- a/kombu/utils/encoding.py +++ b/kombu/utils/encoding.py @@ -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): |