VirtualMailManager/config.py
branchv0.7.x
changeset 641 724ac0a4068d
parent 638 0de0b9e75c9f
child 642 4cd9d0a9f42f
--- a/VirtualMailManager/config.py	Tue Nov 06 21:45:50 2012 +0000
+++ b/VirtualMailManager/config.py	Tue Nov 06 23:23:55 2012 +0000
@@ -357,12 +357,14 @@
         Raises a ConfigError if the configuration syntax is
         invalid.
         """
-        self._cfg_file = open(self._cfg_filename, 'r')
         try:
+            self._cfg_file = open(self._cfg_filename, 'r')
             self.readfp(self._cfg_file)
         except (MissingSectionHeaderError, ParsingError), err:
             raise ConfigError(str(err), CONF_ERROR)
-        self._cfg_file.close()
+        finally:
+            if self._cfg_file and not self._cfg_file.closed:
+                self._cfg_file.close()
 
     def check(self):
         """Performs a configuration check.