From 911c5e0ca388a0741fd082d25ca8cf34fb19eae4 Mon Sep 17 00:00:00 2001 From: ndparker Date: Mon, 23 Oct 2017 09:32:14 +0200 Subject: [PATCH] try latin-1 if utf-8 doesn't work, when decoding exception strings --- rq/worker.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rq/worker.py b/rq/worker.py index 2a280cc..dd9d0bc 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -779,7 +779,10 @@ class Worker(object): def _get_safe_exception_string(exc_strings): """Ensure list of exception strings is decoded on Python 2 and joined as one string safely.""" if sys.version_info[0] < 3: - exc_strings = [exc.decode("utf-8") for exc in exc_strings] + try: + exc_strings = [exc.decode("utf-8") for exc in exc_strings] + except ValueError: + exc_strings = [exc.decode("latin-1") for exc in exc_strings] return ''.join(exc_strings) def push_exc_handler(self, handler_func):