From 28d96a1a78d5257030d746e618c1b59c9e903bcc Mon Sep 17 00:00:00 2001 From: Failure404 <33394205+Failure404@users.noreply.github.com> Date: Wed, 13 Feb 2019 14:41:56 +0100 Subject: [PATCH] 'str' object has no attribute 'decode' I am trying to use user caching, after setting "cache-storage=db" I am getting File "/usr/lib/python3/dist-packages/xclib/utf8.py", line 19, in unutf8 return u.decode('utf-8', opts) AttributeError: 'str' object has no attribute 'decode' It seems like the object is already decoded. With this fix I was able to successfully enable user caching. --- xclib/utf8.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xclib/utf8.py b/xclib/utf8.py index d1e3914..911cc64 100644 --- a/xclib/utf8.py +++ b/xclib/utf8.py @@ -16,8 +16,11 @@ def unutf8(u, opts='strict'): traceback.print_exc() return 'illegal-utf8-sequence-' + dec else: - return u.decode('utf-8', opts) - + try: + return u.decode('utf-8', opts) + except AttributeError: + pass + def utf8l(l): '''Encode a copy of the list, converted to UTF-8''' return list(map(utf8, l))