summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/core/actions.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 3b1fc47a..ab97d81c 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -343,18 +343,19 @@ class Actions(FileManagerAware, SettingsAware):
         Load a config file.
         """
         filename = os.path.expanduser(filename)
-        for line in open(filename, 'r'):
-            line = line.lstrip().rstrip("\r\n")
-            if line.startswith("#") or not line.strip():
-                continue
-            try:
-                self.execute_console(line)
-            except Exception as e:
-                if ranger.arg.debug:
-                    raise
-                else:
-                    self.notify('Error in line `%s\':\n  %s' %
-                            (line, str(e)), bad=True)
+        with open(filename, 'r') as f:
+            for line in f:
+                line = line.lstrip().rstrip("\r\n")
+                if line.startswith("#") or not line.strip():
+                    continue
+                try:
+                    self.execute_console(line)
+                except Exception as e:
+                    if ranger.arg.debug:
+                        raise
+                    else:
+                        self.notify('Error in line `%s\':\n  %s' %
+                                (line, str(e)), bad=True)
 
     def execute_file(self, files, **kw):
         """Uses the "rifle" module to open/execute a file