From f5001a0e361357d53e1c2d5cff9c932afc465340 Mon Sep 17 00:00:00 2001 From: Adam Wen Date: Mon, 20 Oct 2014 10:39:27 +0800 Subject: [PATCH] fix decode error in py3. --- rq/compat/__init__.py | 4 +++- rq/job.py | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rq/compat/__init__.py b/rq/compat/__init__.py index 5e660b5..3095983 100644 --- a/rq/compat/__init__.py +++ b/rq/compat/__init__.py @@ -69,7 +69,9 @@ else: string_types = (str, unicode) def as_text(v): - return v + if v is None: + return None + return v.decode('utf-8') def decode_redis_hash(h): return h diff --git a/rq/job.py b/rq/job.py index 6ba0807..e8080f8 100644 --- a/rq/job.py +++ b/rq/job.py @@ -407,8 +407,7 @@ class Job(object): self.created_at = to_date(as_text(obj.get('created_at'))) self.origin = as_text(obj.get('origin')) - self.description = (as_text(obj.get('description')).decode('utf-8') - if obj.get('description') else None) + self.description = as_text(obj.get('description')) self.enqueued_at = to_date(as_text(obj.get('enqueued_at'))) self.ended_at = to_date(as_text(obj.get('ended_at'))) self._result = unpickle(obj.get('result')) if obj.get('result') else None # noqa