diff options
-rwxr-xr-x | ranger/config/commands.py | 17 | ||||
-rw-r--r-- | ranger/ext/img_display.py | 7 |
2 files changed, 24 insertions, 0 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py index 299f17c2..f11e0e83 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -776,14 +776,23 @@ class load_copy_buffer(Command): copy_buffer_filename = 'copy_buffer' def execute(self): + import sys from ranger.container.file import File from os.path import exists fname = self.fm.datapath(self.copy_buffer_filename) + fobj = None try: fobj = open(fname, 'r') except OSError: + if sys.version_info[0] < 3: + raise + except IOError: + if sys.version_info[0] >= 3: + raise + if fobj is None: return self.fm.notify( "Cannot open %s" % (fname or self.copy_buffer_filename), bad=True) + self.fm.copy_buffer = set(File(g) for g in fobj.read().split("\n") if exists(g)) fobj.close() @@ -799,11 +808,19 @@ class save_copy_buffer(Command): copy_buffer_filename = 'copy_buffer' def execute(self): + import sys fname = None fname = self.fm.datapath(self.copy_buffer_filename) + fobj = None try: fobj = open(fname, 'w') except OSError: + if sys.version_info[0] < 3: + raise + except IOError: + if sys.version_info[0] >= 3: + raise + if fobj is None: return self.fm.notify("Cannot open %s" % (fname or self.copy_buffer_filename), bad=True) fobj.write("\n".join(fobj.path for fobj in self.fm.copy_buffer)) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index c55d835e..e4740407 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -306,6 +306,13 @@ class ITerm2ImageDisplayer(ImageDisplayer, FileManagerAware): file_handle.seek(1, 1) height, width = struct.unpack('>HH', file_handle.read(4)) except OSError: + if sys.version_info[0] < 3: + raise + file_handle.close() + return 0, 0 + except IOError: + if sys.version_info[0] >= 3: + raise file_handle.close() return 0, 0 else: |