aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bachelier <laurent@bachelier.name>2010-01-13 20:47:20 +0100
committerLaurent Bachelier <laurent@bachelier.name>2010-01-13 20:47:20 +0100
commitba72602d2333cf0f499d4e6a981c55a4e11b1f52 (patch)
treeb8b151f246d282d802ddb770aeb04c193aaec3d8
parentFixed symlinks relative path on subdirectories (diff)
downloadconfman-ba72602d2333cf0f499d4e6a981c55a4e11b1f52.tar.xz
Close the file after opening it
-rw-r--r--confman.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/confman.py b/confman.py
index 4faf587..43e86f8 100644
--- a/confman.py
+++ b/confman.py
@@ -1,3 +1,5 @@
+from __future__ import with_statement
+
import os
import re
@@ -115,8 +117,8 @@ class ProgrammableConfigAction(ConfigAction):
source = self.source_path()
try:
- exec compile(open(source).read(), source, 'exec') \
- in exec_env
+ with open(source, "r") as file:
+ exec compile(file.read(), source, 'exec') in exec_env
except SymlinkForwarder as e:
self.proxy = SymlinkConfigAction(self.config, self.relpath, e.filename, self.dest)
except IgnoreForwarder as e: