summary refs log tree commit diff stats
diff options
context:
space:
mode:
authornfnty <git@nfnty.se>2017-01-25 12:24:53 +0100
committernfnty <git@nfnty.se>2017-01-25 12:33:08 +0100
commit00dcb843fb0caa9a01ed445c4f4189da74864f42 (patch)
treea1cc42566bf9eaff114efad5528695287cf99143
parent8fe41bbf2b97d0dd6bbeb73a2b18db27f934b08e (diff)
downloadranger-00dcb843fb0caa9a01ed445c4f4189da74864f42.tar.gz
core.loader: `safeDecode()`: Do not try to decode with encoding `None`
-rw-r--r--ranger/core/loader.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/ranger/core/loader.py b/ranger/core/loader.py
index e890c11f..1033d154 100644
--- a/ranger/core/loader.py
+++ b/ranger/core/loader.py
@@ -269,8 +269,9 @@ def safeDecode(string):  # pylint: disable=invalid-name
         return string.decode("utf-8")
     except UnicodeDecodeError:
         if HAVE_CHARDET:
-            codec = chardet.detect(string)["encoding"]
-            return string.decode(codec, 'ignore')
+            encoding = chardet.detect(string)["encoding"]
+            if encoding:
+                return string.decode(encoding, 'ignore')
         return ""