Move the DOM unlink call to a finally block. (trunk r15216)
authorZac Medico <zmedico@gentoo.org>
Fri, 29 Jan 2010 18:52:36 +0000 (18:52 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 29 Jan 2010 18:52:36 +0000 (18:52 -0000)
svn path=/main/branches/2.1.7/; revision=15266

pym/repoman/utilities.py

index 5ce3867376b6e5bcc0b84874d9393572054a5c4e..8a2c0f0c63f4b954d766827ece2e73845228bf1a 100644 (file)
@@ -124,28 +124,30 @@ def parse_metadata_use(mylines, uselist=None):
                raise exception.ParseError("metadata.xml: %s" % (e,))
 
        try:
-               usetag = metadatadom.getElementsByTagName("use")
-               if not usetag:
+
+               try:
+                       usetag = metadatadom.getElementsByTagName("use")
+                       if not usetag:
+                               return uselist
+               except NotFoundErr:
                        return uselist
-       except NotFoundErr:
-               return uselist
 
-       try:
-               flags = usetag[0].getElementsByTagName("flag")
-       except NotFoundErr:
-               raise exception.ParseError("metadata.xml: " + \
-                       "Malformed input: missing 'flag' tag(s)")
-
-       for flag in flags:
-               pkg_flag = flag.getAttribute("name")
-               if not pkg_flag:
+               try:
+                       flags = usetag[0].getElementsByTagName("flag")
+               except NotFoundErr:
                        raise exception.ParseError("metadata.xml: " + \
-                               "Malformed input: missing 'name' attribute for 'flag' tag")
-               uselist.append(pkg_flag)
-
-       metadatadom.unlink()
-       return uselist
+                               "Malformed input: missing 'flag' tag(s)")
+
+               for flag in flags:
+                       pkg_flag = flag.getAttribute("name")
+                       if not pkg_flag:
+                               raise exception.ParseError("metadata.xml: " + \
+                                       "Malformed input: missing 'name' attribute for 'flag' tag")
+                       uselist.append(pkg_flag)
+               return uselist
 
+       finally:
+               metadatadom.unlink()
 
 def FindPackagesToScan(settings, startdir, reposplit):
        """ Try to find packages that need to be scanned