Mercurial > hg
changeset 14970:592e45b7d43e
wireproto: use safehasattr or getattr instead of hasattr
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 25 Jul 2011 16:05:01 -0500 |
parents | a3f97038c1c2 |
children | 0b21ae0a2366 |
files | mercurial/wireproto.py |
diffstat | 1 files changed, 4 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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,))