summary refs log tree commit diff stats
diff options
context:
space:
mode:
-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 ""