wireproto: use safehasattr or getattr instead of hasattr
authorAugie Fackler <durin42@gmail.com>
Mon, 25 Jul 2011 16:05:01 -0500
changeset 14970 592e45b7d43e
parent 14969 a3f97038c1c2
child 14971 0b21ae0a2366
wireproto: use safehasattr or getattr instead of hasattr
mercurial/wireproto.py
--- a/mercurial/wireproto.py	Mon Jul 25 16:04:44 2011 -0500
+++ b/mercurial/wireproto.py	Mon Jul 25 16:05:01 2011 -0500
@@ -17,7 +17,7 @@
 class future(object):
     '''placeholder for a value to be set later'''
     def set(self, value):
-        if hasattr(self, 'value'):
+        if util.safehasattr(self, 'value'):
             raise error.RepoError("future is already set")
         self.value = value
 
@@ -58,8 +58,9 @@
         req, rsp = [], []
         for name, args, opts, resref in self.calls:
             mtd = getattr(self.remote, name)
-            if hasattr(mtd, 'batchable'):
-                batchable = getattr(mtd, 'batchable')(mtd.im_self, *args, **opts)
+            batchablefn = getattr(mtd, 'batchable', None)
+            if batchablefn is not None:
+                batchable = batchablefn(mtd.im_self, *args, **opts)
                 encargsorres, encresref = batchable.next()
                 if encresref:
                     req.append((name, encargsorres,))