diff options
author | nfnty <git@nfnty.se> | 2017-01-28 23:34:37 +0100 |
---|---|---|
committer | nfnty <git@nfnty.se> | 2017-01-28 23:50:22 +0100 |
commit | 2a0af8e87cb9f2bda2857154f33ceee019bf3f9c (patch) | |
tree | ad70def871ef98ba186a485d505005a9b3641fd8 /ranger | |
parent | e9d8f70031690cf34a4fddb51e9c422260b553a8 (diff) | |
download | ranger-2a0af8e87cb9f2bda2857154f33ceee019bf3f9c.tar.gz |
container.file: File.firstbytes: Handle `UnicodeDecodeError`
Fixes #784
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/container/file.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ranger/container/file.py b/ranger/container/file.py index e0b9922c..88097a2c 100644 --- a/ranger/container/file.py +++ b/ranger/container/file.py @@ -55,7 +55,10 @@ class File(FileSystemObject): if self._firstbytes is None: try: with open(self.path, 'r') as fobj: - self._firstbytes = fobj.read(N_FIRST_BYTES) + try: + self._firstbytes = fobj.read(N_FIRST_BYTES) + except UnicodeDecodeError: + return None except OSError: return None return self._firstbytes |