about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-10-02 21:12:32 +0200
committerhut <hut@lavabit.com>2011-10-02 21:12:32 +0200
commitc24687524b8faca37a48ac53c90331ea2308542f (patch)
tree42623988f99757fdab884218b15263b11fd23b46
parent1f7f9be193dee02b93c4b8d49857acef788edbd5 (diff)
downloadranger-c24687524b8faca37a48ac53c90331ea2308542f.tar.gz
core.actions: REALLY fix that decoding error
-rw-r--r--ranger/core/actions.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index ef616fd1..f4aec81a 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -639,7 +639,14 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 						data['foundpreview'] = False
 					elif exit == 2:
 						f = codecs.open(path, 'r', errors='ignore')
-						data[(-1, -1)] = f.read(1024 * 32)
+						try:
+							data[(-1, -1)] = f.read(1024 * 32)
+						except UnicodeDecodeError:
+							f.close()
+							f = codecs.open(path, 'r', encoding='latin-1',
+									errors='ignore')
+							data[(-1, -1)] = f.read(1024 * 32)
+						f.close()
 					else:
 						data[(-1, -1)] = None
 					if self.env.cf.realpath == path: