glsa.py: use try/finally for urlopen
authorZac Medico <zmedico@gentoo.org>
Wed, 17 Oct 2012 22:57:38 +0000 (15:57 -0700)
committerZac Medico <zmedico@gentoo.org>
Wed, 17 Oct 2012 22:57:38 +0000 (15:57 -0700)
Fixes this error reported with python 2.7.3:

AttributeError: addinfourl instance has no attribute '__exit__'

pym/portage/glsa.py

index f26dc8be28cdc7b7e9812bc31ae162128398482f..d3c3b3da78b68559b776f1df214e806aa0daf913 100644 (file)
@@ -473,8 +473,13 @@ class Glsa:
                        myurl = "file://"+self.nr
                else:
                        myurl = repository + "glsa-%s.xml" % str(self.nr)
-               with urllib_request_urlopen(myurl) as f:
+
+               f = urllib_request_urlopen(myurl)
+               try:
                        self.parse(f)
+               finally:
+                       f.close()
+
                return None
 
        def parse(self, myfile):