changeset 30241:cac4ca036dff stable

httppeer: make __del__ access to self.urlopener more safe Some errors could in some cases show unfortunate scary and confusing warnings from the httppeer delstructors: abort: nodename nor servname provided, or not known Exception AttributeError: "'httpspeer' object has no attribute 'urlopener'" in <bound method httpspeer.__del__ of <mercurial.httppeer.httpspeer object at 0x106e1f5d0>> ignored``` To mute that, take 7b15dd9125b3 to the next level and use getattr in __del__.
author Mads Kiilerich <madski@unity3d.com>
date Mon, 31 Oct 2016 13:43:48 +0100
parents 8237c3359db5
children 389cbfe63586
files mercurial/httppeer.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/httppeer.py	Sun Oct 30 06:15:09 2016 +0900
+++ b/mercurial/httppeer.py	Mon Oct 31 13:43:48 2016 +0100
@@ -63,8 +63,9 @@
         self.requestbuilder = urlreq.request
 
     def __del__(self):
-        if self.urlopener:
-            for h in self.urlopener.handlers:
+        urlopener = getattr(self, 'urlopener', None)
+        if urlopener:
+            for h in urlopener.handlers:
                 h.close()
                 getattr(h, "close_all", lambda : None)()