VirtualMailManager/mailbox.py
branchv0.7.x
changeset 642 4cd9d0a9f42f
parent 568 14abdd04ddf5
child 643 df1e3b67882a
--- a/VirtualMailManager/mailbox.py	Tue Nov 06 23:23:55 2012 +0000
+++ b/VirtualMailManager/mailbox.py	Sun Nov 11 16:53:52 2012 +0000
@@ -206,11 +206,9 @@
         """Writes all created mailboxes to the subscriptions file."""
         if not self._boxes:
             return
-        subscriptions = open('subscriptions', 'w')
-        subscriptions.write('\n'.join(self._boxes))
-        subscriptions.write('\n')
-        subscriptions.flush()
-        subscriptions.close()
+        with open('subscriptions', 'w') as subscriptions:
+            subscriptions.write('\n'.join(self._boxes))
+            subscriptions.write('\n')
         os.chown('subscriptions', self._user.uid, self._user.gid)
         os.chmod('subscriptions', self.__class__.FILE_MODE)
         del self._boxes[:]