Don't use try/finally to close atomic_ofstream since we don't want to
authorZac Medico <zmedico@gentoo.org>
Thu, 8 May 2008 10:33:30 +0000 (10:33 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 8 May 2008 10:33:30 +0000 (10:33 -0000)
call close() on this stream if an error occurs.

svn path=/main/trunk/; revision=10231

pym/portage/dbapi/vartree.py

index f433789cdac3bd286e9594eda4d81671ba412425..abc7916c8e51e0e9775cd2914537c8ab7206951a 100644 (file)
@@ -2313,24 +2313,22 @@ class dblink(object):
                        for filename in collisions:
                                del blocker_contents[filename]
                        f = atomic_ofstream(os.path.join(blocker.dbdir, "CONTENTS"))
-                       try:
-                               for filename in sorted(blocker_contents):
-                                       entry_data = blocker_contents[filename]
-                                       entry_type = entry_data[0]
-                                       relative_filename = filename[destroot_len:]
-                                       if entry_type == "obj":
-                                               entry_type, mtime, md5sum = entry_data
-                                               line = "%s %s %s %s\n" % \
-                                                       (entry_type, relative_filename, md5sum, mtime)
-                                       elif entry_type == "sym":
-                                               entry_type, mtime, link = entry_data
-                                               line = "%s %s -> %s %s\n" % \
-                                                       (entry_type, relative_filename, link, mtime)
-                                       else: # dir, dev, fif
-                                               line = "%s %s\n" % (entry_type, relative_filename)
-                                       f.write(line)
-                       finally:
-                               f.close()
+                       for filename in sorted(blocker_contents):
+                               entry_data = blocker_contents[filename]
+                               entry_type = entry_data[0]
+                               relative_filename = filename[destroot_len:]
+                               if entry_type == "obj":
+                                       entry_type, mtime, md5sum = entry_data
+                                       line = "%s %s %s %s\n" % \
+                                               (entry_type, relative_filename, md5sum, mtime)
+                               elif entry_type == "sym":
+                                       entry_type, mtime, link = entry_data
+                                       line = "%s %s -> %s %s\n" % \
+                                               (entry_type, relative_filename, link, mtime)
+                               else: # dir, dev, fif
+                                       line = "%s %s\n" % (entry_type, relative_filename)
+                               f.write(line)
+                       f.close()
 
                # Due to mtime granularity, mtime checks do not always properly
                # invalidate vardbapi caches.