From c24687524b8faca37a48ac53c90331ea2308542f Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 2 Oct 2011 21:12:32 +0200 Subject: core.actions: REALLY fix that decoding error --- ranger/core/actions.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'ranger/core/actions.py') 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: -- cgit 1.4.1-2-gfad0