diff options
author | nfnty <git@nfnty.se> | 2017-01-25 12:24:53 +0100 |
---|---|---|
committer | nfnty <git@nfnty.se> | 2017-01-25 12:33:08 +0100 |
commit | 00dcb843fb0caa9a01ed445c4f4189da74864f42 (patch) | |
tree | a1cc42566bf9eaff114efad5528695287cf99143 /ranger | |
parent | 8fe41bbf2b97d0dd6bbeb73a2b18db27f934b08e (diff) | |
download | ranger-00dcb843fb0caa9a01ed445c4f4189da74864f42.tar.gz |
core.loader: `safeDecode()`: Do not try to decode with encoding `None`
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/core/loader.py | 5 |
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 "" |