[pitivi] settings: Fix handling of OSError



commit f829c46d35315e2d91d19dd366da81a76c38f463
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Wed May 6 10:18:30 2015 +0200

    settings: Fix handling of OSError

 pitivi/settings.py |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
---
diff --git a/pitivi/settings.py b/pitivi/settings.py
index 84a524f..d85cfac 100644
--- a/pitivi/settings.py
+++ b/pitivi/settings.py
@@ -230,11 +230,10 @@ class GlobalSettings(GObject.Object):
                 else:
                     self._config.remove_option(section, key)
         try:
-            file = open(conf_file_path, 'w')
-        except IOError as OSError:
+            with open(conf_file_path, 'w') as file:
+                self._config.write(file)
+        except (IOError, OSError):
             return
-        self._config.write(file)
-        file.close()
 
     def storeSettings(self):
         """


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]