Handle AttributeError inside atomic_ofstream.__del__. Thanks to Cardoe for
authorZac Medico <zmedico@gentoo.org>
Tue, 5 Jan 2010 19:02:44 +0000 (19:02 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 5 Jan 2010 19:02:44 +0000 (19:02 -0000)
reporting.

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

pym/portage/util.py

index bb53b078582cd85268e257cefed7fd2796c672a5..ad2b8b9feda8a47bff906608d5df6c5c1f9106da 100644 (file)
@@ -1009,9 +1009,13 @@ class atomic_ofstream(ObjectProxy):
        def __del__(self):
                """If the user does not explicitely call close(), it is
                assumed that an error has occurred, so we abort()."""
-               f = object.__getattribute__(self, '_file')
-               if not f.closed:
-                       self.abort()
+               try:
+                       f = object.__getattribute__(self, '_file')
+               except AttributeError:
+                       pass
+               else:
+                       if not f.closed:
+                               self.abort()
                # ensure destructor from the base class is called
                base_destructor = getattr(ObjectProxy, '__del__', None)
                if base_destructor is not None: