labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1519344 - /labs/panopticon/src/asf/utils/config.py
Date Mon, 02 Sep 2013 05:38:38 GMT
Author: adc
Date: Mon Sep  2 05:38:37 2013
New Revision: 1519344

URL: http://svn.apache.org/r1519344
Log:
Use contextlib to close file.

Modified:
    labs/panopticon/src/asf/utils/config.py

Modified: labs/panopticon/src/asf/utils/config.py
URL: http://svn.apache.org/viewvc/labs/panopticon/src/asf/utils/config.py?rev=1519344&r1=1519343&r2=1519344&view=diff
==============================================================================
--- labs/panopticon/src/asf/utils/config.py (original)
+++ labs/panopticon/src/asf/utils/config.py Mon Sep  2 05:38:37 2013
@@ -17,6 +17,7 @@
 # under the License.
 #
 import ConfigParser
+import contextlib
 import os
 
 
@@ -52,5 +53,6 @@ class load_config(object):
 
     def __exit__(self, exception_type, exception_value, traceback):
         if not exception_value:
-            self.config.write(open(TOOLS_CFG_FILE, 'w'))
+            with contextlib.closing(open(TOOLS_CFG_FILE, 'w')) as fp:
+                self.config.write(fp)
         return False



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message